@Test public void test_int32_t() throws IOException { for (Long exp : expected_int32) { SignedInteger result = binFileReader.int32_t(); assertEquals("int32_t " + exp + " asInt()", exp, result.asLong()); assertEquals( "int32_t " + exp + " getSignedValue()", (Integer) exp.intValue(), result.getSignedValue()); assertEquals("int32_t " + exp + " toString()", exp.toString(), result.toString()); } }
@Test public void test_manuel_int32_t() throws IOException { // 6B 73 68 6F // 107 115 104 111 // 29547 28520 // 1869116267 byte[] input1 = {107, 115, 104, 111}; // 6B 73 68 6F Long expected1 = 1869116267L; // 1869116267 BinFileReader binFileReader = new BinFileReader(new BufferedInputStream(new ByteArrayInputStream(input1))); SignedInteger result1 = binFileReader.int32_t(); assertEquals("int32_t6B 73 68 6F asLong() = 1869116267", expected1, result1.asLong()); assertEquals( "int32_t6B 73 68 6F getSignedValue() = 1869116267", (Integer) expected1.intValue(), result1.getSignedValue()); byte[] input2 = {32, 75, -61, -68}; // 20 4B C3 BC Long expected2 = -1128051936L; // -1128051936 binFileReader = new BinFileReader(new BufferedInputStream(new ByteArrayInputStream(input2))); SignedInteger result2 = binFileReader.int32_t(); assertEquals("int32_t20 4B C3 BC asLong() = -1128051936", expected2, result2.asLong()); assertEquals( "int32_t20 4B C3 BC getSignedValue() = -1128051936", (Integer) expected2.intValue(), result2.getSignedValue()); }