| 8 | import org.junit.jupiter.params.provider.MethodSource; |
| 9 | |
| 10 | public class AtbashTest { |
| 11 | |
| 12 | @ParameterizedTest |
| 13 | @MethodSource("cipherTestProvider") |
| 14 | public void testAtbashCipher(String input, String expected) { |
| 15 | AtbashCipher cipher = new AtbashCipher(input); |
| 16 | assertEquals(expected, cipher.convert()); |
| 17 | } |
| 18 | |
| 19 | private static Stream<Arguments> cipherTestProvider() { |
| 20 | return Stream.of( |
| 21 | // Basic tests with lowercase and uppercase |
| 22 | Arguments.of("Hello", "Svool"), Arguments.of("WORLD", "DLIOW"), |
| 23 | |
| 24 | // Mixed case with spaces and punctuation |
| 25 | Arguments.of("Hello World!", "Svool Dliow!"), Arguments.of("123 ABC xyz", "123 ZYX cba"), |
| 26 | |
| 27 | // Palindromes and mixed cases |
| 28 | Arguments.of("madam", "nzwzn"), Arguments.of("Palindrome", "Kzormwilnv"), |
| 29 | |
| 30 | // Non-alphabetic characters should remain unchanged |
| 31 | Arguments.of("@cipher 123!", "@xrksvi 123!"), Arguments.of("no-change", "ml-xszmtv"), |
| 32 | |
| 33 | // Empty string and single characters |
| 34 | Arguments.of("", ""), Arguments.of("A", "Z"), Arguments.of("z", "a"), |
| 35 | |
| 36 | // Numbers and symbols |
| 37 | Arguments.of("!@#123", "!@#123"), |
| 38 | |
| 39 | // Full sentence with uppercase, lowercase, symbols, and numbers |
| 40 | Arguments.of("Hello World! 123, @cipher abcDEF ZYX 987 madam zzZ Palindrome!", "Svool Dliow! 123, @xrksvi zyxWVU ABC 987 nzwzn aaA Kzormwilnv!"), |
| 41 | Arguments.of("Svool Dliow! 123, @xrksvi zyxWVU ABC 987 nzwzn aaA Kzormwilnv!", "Hello World! 123, @cipher abcDEF ZYX 987 madam zzZ Palindrome!")); |
| 42 | } |
| 43 | } |
nothing calls this directly
no outgoing calls
no test coverage detected