diff --git a/pom.xml b/pom.xml index 0a094f7..dd19521 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,13 @@ test + + org.junit.jupiter + junit-jupiter-params + 5.9.3 + test + + org.mockito mockito-core diff --git a/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java index f423aa2..c00704a 100644 --- a/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java +++ b/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestTrifid.java @@ -20,6 +20,8 @@ import static org.mockito.Mockito.verify; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -473,34 +475,18 @@ public class TestTrifid{ verify(logger, times(1)).debug("Getting character at {} {} {}", 2, 0, 1); } - @Test - public void testGetChar_largeX(){ + @ParameterizedTest + @CsvSource({ + "3, 1, 2", + "0, 3, 2", + "0, 1, 3" + }) + public void testGetChar_invalidLocation(int x, int y, int z){ cipher.grid = grid; + CharLocation location = cipher.new CharLocation(x, y, z); assertThrows(InvalidCharacterException.class, () -> { - cipher.getChar(cipher.new CharLocation(3, 1, 2)); - }); - - verify(logger, never()).debug(eq("Getting character at {} {} {}"), anyInt(), anyInt(), anyInt()); - } - - @Test - public void testGetChar_largeY(){ - cipher.grid = grid; - - assertThrows(InvalidCharacterException.class, () -> { - cipher.getChar(cipher.new CharLocation(0, 3, 2)); - }); - - verify(logger, never()).debug(eq("Getting character at {} {} {}"), anyInt(), anyInt(), anyInt()); - } - - @Test - public void testGetChar_largeZ(){ - cipher.grid = grid; - - assertThrows(InvalidCharacterException.class, () -> { - cipher.getChar(cipher.new CharLocation(0, 1, 3)); + cipher.getChar(location); }); verify(logger, never()).debug(eq("Getting character at {} {} {}"), anyInt(), anyInt(), anyInt());