コード例 #1
0
  @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());
  }
コード例 #2
0
 @Test
 public void test_int64_t() throws IOException {
   for (Long exp : expected_int64) {
     SignedLong result = binFileReader.int64_t();
     assertEquals("int64_t " + exp + " getSignedValue()", exp, result.getSignedValue());
     assertEquals("int64_t " + exp + " toString()", exp.toString(), result.toString());
   }
 }
コード例 #3
0
 @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());
   }
 }
コード例 #4
0
 @Test
 public void test_uint64_t() throws IOException {
   for (Long exp : expected_uint64) {
     UnsignedLong result = binFileReader.uint64_t();
     assertEquals("uint64_t " + exp + " getSignedValue()", exp, result.getSignedValue());
     assertEquals(
         "uint64_t " + exp + " toString()",
         Long.toString(exp < 0 ? exp + 256 : exp),
         result.toString());
   }
 }