Skip to content

Commit fa0562e

Browse files
committed
Test Context toString has debugging info
1 parent f39003c commit fa0562e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,33 @@ void decode(final byte[] pArray, final int i, final int length, final Context co
5151
};
5252
}
5353

54+
/**
55+
* Test the Context string representation has debugging info.
56+
* This is not part of the API and the test should be changed if the string
57+
* format is updated.
58+
*/
59+
@Test
60+
public void testContextToString() {
61+
final Context context = new Context();
62+
context.buffer = new byte[3];
63+
context.currentLinePos = 13;
64+
context.eof = true;
65+
context.ibitWorkArea = 777;
66+
context.lbitWorkArea = 999;
67+
context.modulus = 5;
68+
context.pos = 42;
69+
context.readPos = 981;
70+
final String text = context.toString();
71+
Assert.assertTrue(text.contains("[0, 0, 0]"));
72+
Assert.assertTrue(text.contains("13"));
73+
Assert.assertTrue(text.contains("true"));
74+
Assert.assertTrue(text.contains("777"));
75+
Assert.assertTrue(text.contains("999"));
76+
Assert.assertTrue(text.contains("5"));
77+
Assert.assertTrue(text.contains("42"));
78+
Assert.assertTrue(text.contains("981"));
79+
}
80+
5481
@Test
5582
public void testBaseNCodec() {
5683
assertNotNull(codec);

0 commit comments

Comments
 (0)