From fa0562e71e2661768c4d2e324ff978aa2af1be08 Mon Sep 17 00:00:00 2001 From: Alex Herbert Date: Fri, 28 Aug 2020 00:18:19 +0100 Subject: [PATCH] Test Context toString has debugging info --- .../commons/codec/binary/BaseNCodecTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java b/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java index 1b1d0b56bc..3b0800b1b3 100644 --- a/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java +++ b/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java @@ -51,6 +51,33 @@ void decode(final byte[] pArray, final int i, final int length, final Context co }; } + /** + * Test the Context string representation has debugging info. + * This is not part of the API and the test should be changed if the string + * format is updated. + */ + @Test + public void testContextToString() { + final Context context = new Context(); + context.buffer = new byte[3]; + context.currentLinePos = 13; + context.eof = true; + context.ibitWorkArea = 777; + context.lbitWorkArea = 999; + context.modulus = 5; + context.pos = 42; + context.readPos = 981; + final String text = context.toString(); + Assert.assertTrue(text.contains("[0, 0, 0]")); + Assert.assertTrue(text.contains("13")); + Assert.assertTrue(text.contains("true")); + Assert.assertTrue(text.contains("777")); + Assert.assertTrue(text.contains("999")); + Assert.assertTrue(text.contains("5")); + Assert.assertTrue(text.contains("42")); + Assert.assertTrue(text.contains("981")); + } + @Test public void testBaseNCodec() { assertNotNull(codec);