@Test public void test_manuel_uint32_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))); UnsignedInteger result1 = binFileReader.uint32_t(); assertEquals("uint32_t6B 73 68 6F asLong() = 1869116267", expected1, result1.asLong()); assertEquals( "uint32_t6B 73 68 6F getSignedValue() = 1869116267", (Integer) expected1.intValue(), result1.getSignedValue()); byte[] input2 = {32, 75, -61, -68}; // 20 4B C3 BC Long expected2 = 3166915360L; // 3166915360 binFileReader = new BinFileReader(new BufferedInputStream(new ByteArrayInputStream(input2))); UnsignedInteger result2 = binFileReader.uint32_t(); assertEquals("uint32_t20 4B C3 BC asLong() = 3166915360", expected2, result2.asLong()); assertEquals( "uint32_t20 4B C3 BC getSignedValue() = -1128051936", (Integer) expected2.intValue(), result2.getSignedValue()); }
@Test public void test_uint32_t() throws IOException { for (Long exp : expected_uint32) { UnsignedInteger result = binFileReader.uint32_t(); assertEquals("uint32_t " + exp + " asInt()", exp, result.asLong()); assertEquals( "uint32_t " + exp + " getSignedValue()", (Integer) exp.intValue(), result.getSignedValue()); assertEquals( "uint32_t " + exp + " toString()", Long.toString((((exp < 0 ? exp + 256 : exp)))), result.toString()); } }