Update test coverage

This commit is contained in:
2023-06-30 21:56:09 -04:00
parent 3f5e44a27f
commit 7f7b5204e3
2 changed files with 32 additions and 1 deletions

View File

@@ -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;

View File

@@ -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, () -> {