### Question:
BytesValue extends Value implements IByteOperations { public IntegerValue convertToIntegerType(ASTElementaryTypeName newType) throws Exception { String s = ""; for (int i = 0; i < value.length; ++i) { s += String.format("%02x", value[i]); } BigInteger unsgnedInteger = new BigInteger(s, 16); ASTElementaryTypeName unsignedType = TypeContainer.getIntegerType(false, type.getBytes() * 8); IntegerValue unsignedIntegerValue = ValueContainer.getBigIntegerValue(unsignedType, unsgnedInteger); if (Type.isSameType(null, unsignedType, newType)) { return unsignedIntegerValue; } else { return unsignedIntegerValue.convertToIntegerType(newType); } } BytesValue(ASTNode type, /*String*/ byte[] value); int getBytesCount(); @Override ASTNode getType(); @Override ASTNode toASTNode(boolean forJavaScript); String toHexConstantString(); @Override Object toJSONRepresentation(); BoolValue isEqualTo(BytesValue other); BoolValue isNotEqualTo(BytesValue other); BoolValue isSmallerThan(BytesValue value); BoolValue isSmallerThanOrEqualTo(BytesValue value); BoolValue isGreaterThan(BytesValue value); BoolValue isGreaterThanOrEqualTo(BytesValue value); BytesValue negateBitwise(); BytesValue bitwiseOr(Value otherValue); BytesValue bitwiseAnd(Value otherValue); BytesValue bitwiseXor(Value otherValue); BytesValue bitwiseShiftLeft(Value value); BytesValue bitwiseShiftRight(Value value); BytesValue indexAccess(Value index); IntegerValue length(); BytesValue convertToBytesType(ASTElementaryTypeName newType); IntegerValue convertToIntegerType(ASTElementaryTypeName newType);  }### Answer:
@Test public void castToIntegerType() throws Exception { BytesTestValues[] ab = new BytesTestValues[]{ new BytesTestValues("bytes1", new byte[]{b(0xff)}, null, 1, null), new BytesTestValues("bytes2", new byte[]{b(0x1), b(0x0)}, null, 2, null) }; IntegerTestValues[] ai = new IntegerTestValues[]{ new IntegerTestValues("int8", null, true, 8, "-1"), new IntegerTestValues("int32", null, true, 32, "256") }; for (int i = 0; i < ab.length; ++i) { BytesTestValues sourceData = ab[i]; IntegerTestValues destData = ai[i]; ASTElementaryTypeName sourceType = TypeContainer.getByteType(sourceData.typeBytes); BytesValue value = new BytesValue(sourceType, sourceData.valueArray); ASTElementaryTypeName destType = TypeContainer.getIntegerType(destData.isSigned, destData.typeBits); IntegerValue resultValue = value.convertToIntegerType(destType); String got = s(resultValue); String wanted = decstring(destData.typeText, destData.operationResult); System.out.println("got " + got + " wanted " + wanted); Assert.assertTrue(got.equals(wanted)); } }