Skip to content

Commit

Permalink
Formatting and remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed Nov 20, 2023
1 parent 4ee02e0 commit ee723b6
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions Tests/com/drew/lang/SequentialAccessTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,28 +241,24 @@ public void testGetNullTerminatedString() throws IOException
}

@Test
public void testGetNullTerminatedStringCursorPositionTest() throws IOException {
public void testGetNullTerminatedStringCursorPositionTest() throws IOException
{
byte NULL = 0x00;
byte[] bytes = new byte[]{0x41, 0x42, NULL, NULL, NULL, 0x43, 0x44, NULL, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; //AB\0\0\0CD\0ABCDEF
SequentialReader reader = createReader(bytes);

/*
tried to read first five values
*/
assertEquals("AB", reader.getNullTerminatedString(5, Charsets.UTF_8).toString());
// try to read first five values
assertEquals("AB", reader.getNullTerminatedString(5, Charsets.UTF_8));

/*
the cursor is after B (third) position
*/
// the cursor is after B (third) position
assertEquals(reader.getPosition(), 3);
reader.skip(2);

assertEquals("CD", reader.getNullTerminatedString(3, Charsets.UTF_8).toString());
assertEquals("CD", reader.getNullTerminatedString(3, Charsets.UTF_8));

assertEquals(reader.getPosition(), 8);
//no need to skip to next position. since there's only one \0 character after "CD"

assertEquals("ABCDEF", reader.getNullTerminatedString(6, Charsets.UTF_8).toString());
assertEquals("ABCDEF", reader.getNullTerminatedString(6, Charsets.UTF_8));
}

@Test
Expand Down

0 comments on commit ee723b6

Please sign in to comment.