diff --git a/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestRailFence.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestRailFence.java index 72dd0a6..c79d64b 100644 --- a/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestRailFence.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestRailFence.java @@ -301,6 +301,27 @@ public class TestRailFence{ verify(logger, times(1)).debug("Fence output '{}'", decodedString.replaceAll("[^a-zA-Z]", "")); } + @Test + public void testDecode_length(){ + cipher.inputString = "aa"; + cipher.fence = new StringBuilder[]{ + new StringBuilder(), + new StringBuilder(), + new StringBuilder() + }; + + cipher.decode(); + + assertEquals("aa", cipher.outputString); + verify(logger, times(1)).debug("Decoding"); + verify(logger, times(1)).debug("Number of characters in the top rail {}", 1); + verify(logger, times(1)).debug("Number of characters in the middle rails {}", 1); + verify(logger, times(1)).debug("Number of characters in the bottom rail {}", 0); + verify(logger, times(1)).debug("Adding characters to the rails"); + verify(logger, times(1)).debug("Appending the bottom rail"); + verify(logger, times(1)).debug("Fence output '{}'", "aa"); + } + @Test public void testGetters(){ cipher.inputString = decodedString; diff --git a/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java index c00704a..3bb65ef 100644 --- a/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java @@ -204,7 +204,7 @@ public class TestTrifid{ } @Test - public void testSetFillIn_nonPrinting(){ + public void testSetFillIn_nonPrintingLow(){ assertThrows(InvalidCharacterException.class, () -> { cipher.setFillIn('\0'); }); @@ -213,6 +213,16 @@ public class TestTrifid{ verify(logger, never()).debug(eq("Setting fill in {}"), anyChar()); } + @Test + public void testSetFill_nonPrintingHigh(){ + assertThrows(InvalidCharacterException.class, () -> { + cipher.setFillIn((char)127); + }); + + assertEquals('+', cipher.fillIn); + verify(logger, never()).debug(eq("Setting fill in {}"), anyChar()); + } + @Test public void testSetFillIn_letter(){ assertThrows(InvalidCharacterException.class, () -> {