コード例 #1
0
 @Test
 public void test_uint8_t() throws IOException {
   for (Integer exp : expected_uint8) {
     UnsignedByte result = binFileReader.uint8_t();
     assertEquals(
         "uint8_t " + Integer.toHexString(exp) + " asInt()",
         (Integer) Byte.toUnsignedInt(exp.byteValue()),
         result.asInt());
     assertEquals(
         "uint8_t " + Integer.toHexString(exp) + " getSignedValue()",
         (Byte) exp.byteValue(),
         result.getSignedValue());
     assertEquals(
         "uint8_t " + Integer.toHexString(exp) + " toString()",
         Integer.toString((((exp < 0 ? exp + 256 : exp)))),
         result.toString());
   }
 }
コード例 #2
0
 @Test
 public void test_manuel_uint8_t() throws IOException {
   // 73 4B C3 BC
   // 115, 75, -61, -68
   byte[] input = {115, 75, -61, -68};
   int[] expected = {0x73, 0x4B, 0xC3, 0xBC};
   BinFileReader binFileReader =
       new BinFileReader(new BufferedInputStream(new ByteArrayInputStream(input)));
   for (int i = 0; i < input.length; i++) {
     UnsignedByte result = binFileReader.uint8_t();
     Integer exp = expected[i];
     assertEquals(
         "uint8_t " + Integer.toHexString(exp) + " asInt()",
         (Integer) Byte.toUnsignedInt(exp.byteValue()),
         result.asInt());
     assertEquals(
         "uint8_t " + Integer.toHexString(exp) + " getSignedValue()",
         (Byte) exp.byteValue(),
         result.getSignedValue());
   }
 }