コード例 #1
0
 @Test
 public void test_string_t_endsWithNull() throws IOException {
   for (String exp : expected_string) {
     String result = binFileReader.string_t(false);
     assertEquals("string_t(length=false)", exp, result);
     assertEquals("string_t(length=false) toString()", exp.toString(), result.toString());
   }
 }
コード例 #2
0
 @Test
 public void test_string_t_length() throws IOException {
   int string_lenght = this.input.length - 1; // ignore the \0 at the end.
   byte[] foo = new byte[string_lenght + 4];
   // Insert the string length at first 4 positions. Is LittleEndian!
   foo[0] = (byte) (string_lenght);
   foo[1] = (byte) (string_lenght >>> 8);
   foo[2] = (byte) (string_lenght >>> 16);
   foo[3] = (byte) (string_lenght >>> 24);
   System.arraycopy(this.input, 0, foo, 4, string_lenght); // ignore the \0 at the end
   this.binFileReader = new BinFileReader(new BufferedInputStream(new ByteArrayInputStream(foo)));
   for (String exp : expected_string) {
     String result = binFileReader.string_t(true);
     assertEquals("string_t(length=true)", exp, result);
     assertEquals("string_t(length=true) toString()", exp.toString(), result.toString());
   }
 }