diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAtbash.java b/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAtbash.java index a754d9e..0c2f81f 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAtbash.java +++ b/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAtbash.java @@ -1,7 +1,7 @@ -//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestAtbash.java -//Matthew Ellison +//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAtbash.java +//Mattrixwv // Created: 07-25-21 -//Modified: 01-04-22 +//Modified: 02-22-22 package com.mattrixwv.CipherStreamJava.monoSubstitution; @@ -18,179 +18,168 @@ public class TestAtbash{ Atbash cipher = new Atbash(true, true, true); //Test lowercase encoding - String input = "abc"; - String correctOutput = "zyx"; - String output = cipher.encode(input); + String inputString = "messagetoencode"; + String correctOutput = "nvhhztvglvmxlwv"; + String output = cipher.encode(inputString); assertEquals("Atbash failed lowercase encoding.", correctOutput, output); //Test uppercase encoding - input = "ABC"; - correctOutput = "ZYX"; - output = cipher.encode(input); + inputString = "MESSAGETOENCODE"; + correctOutput = "NVHHZTVGLVMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed uppercase encoding.", correctOutput, output); - //Test whitespace encoding - input = "abc def"; - correctOutput = "zyx wvu"; - output = cipher.encode(input); + inputString = "message to encode"; + correctOutput = "nvhhztv gl vmxlwv"; + output = cipher.encode(inputString); assertEquals("Atbash failed whitespace encoding.", correctOutput, output); - - //Test symbol decoding - input = "abc-def@"; - correctOutput = "zyx-wvu@"; - output = cipher.encode(input); + //Test symbol encoding + inputString = "message*to+encode"; + correctOutput = "nvhhztv*gl+vmxlwv"; + output = cipher.encode(inputString); assertEquals("Atbash failed symbol encoding.", correctOutput, output); - - //Test mixed case, whitespace, and symbol decoding - input = "The quick brown fox jumps over - the lazy dog"; - correctOutput = "Gsv jfrxp yildm ulc qfnkh levi - gsv ozab wlt"; - output = cipher.encode(input); + //Test mixed case, whitespace, and symbol encoding + inputString = "Message to^encode"; + correctOutput = "Nvhhztv gl^vmxlwv"; + output = cipher.encode(inputString); assertEquals("Atbash failed mixed case, whitespace, and symbol encoding.", correctOutput, output); } + @Test public void testNoCapitalEncode() throws InvalidInputException{ Atbash cipher = new Atbash(false, true, true); //Test lowercase encoding - String input = "abc"; - String correctOutput = "zyx"; - String output = cipher.encode(input); + String inputString = "messagetoencode"; + String correctOutput = "NVHHZTVGLVMXLWV"; + String output = cipher.encode(inputString); assertEquals("Atbash failed no capital lowercase encoding.", correctOutput, output); //Test uppercase encoding - input = "ABC"; - correctOutput = "zyx"; - output = cipher.encode(input); + inputString = "MESSAGETOENCODE"; + correctOutput = "NVHHZTVGLVMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed no capital uppercase encoding.", correctOutput, output); - //Test whitespace encoding - input = "abc def"; - correctOutput = "zyx wvu"; - output = cipher.encode(input); + inputString = "message to encode"; + correctOutput = "NVHHZTV GL VMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed no capital whitespace encoding.", correctOutput, output); - - //Test symbol decoding - input = "abc-def@"; - correctOutput = "zyx-wvu@"; - output = cipher.encode(input); + //Test symbol encoding + inputString = "message*to+encode"; + correctOutput = "NVHHZTV*GL+VMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed no capital symbol encoding.", correctOutput, output); - - //Test mixed case, whitespace, and symbol decoding - input = "The quick brown fox jumps over - the lazy dog"; - correctOutput = "gsv jfrxp yildm ulc qfnkh levi - gsv ozab wlt"; - output = cipher.encode(input); + //Test mixed case, whitespace, and symbol encoding + inputString = "Message to^encode"; + correctOutput = "NVHHZTV GL^VMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed no capital mixed case, whitespace, and symbol encoding.", correctOutput, output); } + @Test public void testNoWhitespaceEncode() throws InvalidInputException{ Atbash cipher = new Atbash(true, false, true); //Test lowercase encoding - String input = "abc"; - String correctOutput = "zyx"; - String output = cipher.encode(input); + String inputString = "messagetoencode"; + String correctOutput = "nvhhztvglvmxlwv"; + String output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace lowercase encoding.", correctOutput, output); //Test uppercase encoding - input = "ABC"; - correctOutput = "ZYX"; - output = cipher.encode(input); + inputString = "MESSAGETOENCODE"; + correctOutput = "NVHHZTVGLVMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace uppercase encoding.", correctOutput, output); - //Test whitespace encoding - input = "abc def"; - correctOutput = "zyxwvu"; - output = cipher.encode(input); + inputString = "message to encode"; + correctOutput = "nvhhztvglvmxlwv"; + output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace whitespace encoding.", correctOutput, output); - - //Test symbol decoding - input = "abc-def@"; - correctOutput = "zyx-wvu@"; - output = cipher.encode(input); + //Test symbol encoding + inputString = "message*to+encode"; + correctOutput = "nvhhztv*gl+vmxlwv"; + output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace symbol encoding.", correctOutput, output); - - //Test mixed case, whitespace, and symbol decoding - input = "The quick brown fox jumps over - the lazy dog"; - correctOutput = "Gsvjfrxpyildmulcqfnkhlevi-gsvozabwlt"; - output = cipher.encode(input); + //Test mixed case, whitespace, and symbol encoding + inputString = "Message to^encode"; + correctOutput = "Nvhhztvgl^vmxlwv"; + output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace mixed case, whitespace, and symbol encoding.", correctOutput, output); } + @Test public void testNoSymbolEncode() throws InvalidInputException{ Atbash cipher = new Atbash(true, true, false); //Test lowercase encoding - String input = "abc"; - String correctOutput = "zyx"; - String output = cipher.encode(input); + String inputString = "messagetoencode"; + String correctOutput = "nvhhztvglvmxlwv"; + String output = cipher.encode(inputString); assertEquals("Atbash failed no symbol lowercase encoding.", correctOutput, output); //Test uppercase encoding - input = "ABC"; - correctOutput = "ZYX"; - output = cipher.encode(input); + inputString = "MESSAGETOENCODE"; + correctOutput = "NVHHZTVGLVMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed no symbol uppercase encoding.", correctOutput, output); - //Test whitespace encoding - input = "abc def"; - correctOutput = "zyx wvu"; - output = cipher.encode(input); + inputString = "message to encode"; + correctOutput = "nvhhztv gl vmxlwv"; + output = cipher.encode(inputString); assertEquals("Atbash failed no symbol whitespace encoding.", correctOutput, output); - - //Test symbol decoding - input = "abc-def@"; - correctOutput = "zyxwvu"; - output = cipher.encode(input); + //Test symbol encoding + inputString = "message*to+encode"; + correctOutput = "nvhhztvglvmxlwv"; + output = cipher.encode(inputString); assertEquals("Atbash failed no symbol symbol encoding.", correctOutput, output); - - //Test mixed case, whitespace, and symbol decoding - input = "The quick brown fox jumps over - the lazy dog"; - correctOutput = "Gsv jfrxp yildm ulc qfnkh levi gsv ozab wlt"; - output = cipher.encode(input); + //Test mixed case, whitespace, and symbol encoding + inputString = "Message to^encode"; + correctOutput = "Nvhhztv glvmxlwv"; + output = cipher.encode(inputString); assertEquals("Atbash failed no symbol mixed case, whitespace, and symbol encoding.", correctOutput, output); } + @Test public void testNoCapitalWhitespaceSymbolEncode() throws InvalidInputException{ Atbash cipher = new Atbash(false, false, false); //Test lowercase encoding - String input = "abc"; - String correctOutput = "zyx"; - String output = cipher.encode(input); + String inputString = "messagetoencode"; + String correctOutput = "NVHHZTVGLVMXLWV"; + String output = cipher.encode(inputString); assertEquals("Atbash failed secure lowercase encoding.", correctOutput, output); //Test uppercase encoding - input = "ABC"; - correctOutput = "zyx"; - output = cipher.encode(input); + inputString = "MESSAGETOENCODE"; + correctOutput = "NVHHZTVGLVMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed secure uppercase encoding.", correctOutput, output); - //Test whitespace encoding - input = "abc def"; - correctOutput = "zyxwvu"; - output = cipher.encode(input); + inputString = "message to encode"; + correctOutput = "NVHHZTVGLVMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed secure whitespace encoding.", correctOutput, output); - - //Test symbol decoding - input = "abc-def@"; - correctOutput = "zyxwvu"; - output = cipher.encode(input); + //Test symbol encoding + inputString = "message*to+encode"; + correctOutput = "NVHHZTVGLVMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed secure symbol encoding.", correctOutput, output); - - //Test mixed case, whitespace, and symbol decoding - input = "The quick brown fox jumps over - the lazy dog"; - correctOutput = "gsvjfrxpyildmulcqfnkhlevigsvozabwlt"; - output = cipher.encode(input); + //Test mixed case, whitespace, and symbol encoding + inputString = "Message to^encode"; + correctOutput = "NVHHZTVGLVMXLWV"; + output = cipher.encode(inputString); assertEquals("Atbash failed secure mixed case, whitespace, and symbol encoding.", correctOutput, output); } @@ -200,179 +189,168 @@ public class TestAtbash{ Atbash cipher = new Atbash(true, true, true); //Test lowercase decoding - String input = "zyx"; - String correctOutput = "abc"; - String output = cipher.decode(input); + String inputString = "nvhhztvglvmxlwv"; + String correctOutput = "messagetoencode"; + String output = cipher.encode(inputString); assertEquals("Atbash failed lowercase decoding.", correctOutput, output); //Test uppercase decoding - input = "ZYX"; - correctOutput = "ABC"; - output = cipher.decode(input); + inputString = "NVHHZTVGLVMXLWV"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed uppercase decoding.", correctOutput, output); - //Test whitespace decoding - input = "zyx wvu"; - correctOutput = "abc def"; - output = cipher.decode(input); + inputString = "nvhhztv gl vmxlwv"; + correctOutput = "message to encode"; + output = cipher.encode(inputString); assertEquals("Atbash failed whitespace decoding.", correctOutput, output); - //Test symbol decoding - input = "zyx-wvu@"; - correctOutput = "abc-def@"; - output = cipher.decode(input); + inputString = "nvhhztv*gl+vmxlwv"; + correctOutput = "message*to+encode"; + output = cipher.encode(inputString); assertEquals("Atbash failed symbol decoding.", correctOutput, output); - //Test mixed case, whitespace, and symbol decoding - input = "Gsv jfrxp yildm ulc qfnkh levi - gsv ozab wlt"; - correctOutput = "The quick brown fox jumps over - the lazy dog"; - output = cipher.decode(input); + inputString = "Nvhhztv gl^vmxlwv"; + correctOutput = "Message to^encode"; + output = cipher.encode(inputString); assertEquals("Atbash failed mixed case, whitespace, and symbol decoding.", correctOutput, output); } + @Test public void testNoCapitalDecode() throws InvalidInputException{ Atbash cipher = new Atbash(false, true, true); //Test lowercase decoding - String input = "zyx"; - String correctOutput = "abc"; - String output = cipher.decode(input); + String inputString = "nvhhztvglvmxlwv"; + String correctOutput = "MESSAGETOENCODE"; + String output = cipher.encode(inputString); assertEquals("Atbash failed no capital lowercase decoding.", correctOutput, output); //Test uppercase decoding - input = "ZYX"; - correctOutput = "abc"; - output = cipher.decode(input); + inputString = "NVHHZTVGLVMXLWV"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed no capital uppercase decoding.", correctOutput, output); - //Test whitespace decoding - input = "zyx wvu"; - correctOutput = "abc def"; - output = cipher.decode(input); + inputString = "nvhhztv gl vmxlwv"; + correctOutput = "MESSAGE TO ENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed no capital whitespace decoding.", correctOutput, output); - //Test symbol decoding - input = "zyx-wvu@"; - correctOutput = "abc-def@"; - output = cipher.decode(input); + inputString = "nvhhztv*gl+vmxlwv"; + correctOutput = "MESSAGE*TO+ENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed no capital symbol decoding.", correctOutput, output); - //Test mixed case, whitespace, and symbol decoding - input = "Gsv jfrxp yildm ulc qfnkh levi - gsv ozab wlt"; - correctOutput = "the quick brown fox jumps over - the lazy dog"; - output = cipher.decode(input); + inputString = "Nvhhztv gl^vmxlwv"; + correctOutput = "MESSAGE TO^ENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed no capital mixed case, whitespace, and symbol decoding.", correctOutput, output); } + @Test public void testNoWhitespaceDecode() throws InvalidInputException{ Atbash cipher = new Atbash(true, false, true); //Test lowercase decoding - String input = "zyx"; - String correctOutput = "abc"; - String output = cipher.decode(input); + String inputString = "nvhhztvglvmxlwv"; + String correctOutput = "messagetoencode"; + String output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace lowercase decoding.", correctOutput, output); //Test uppercase decoding - input = "ZYX"; - correctOutput = "ABC"; - output = cipher.decode(input); + inputString = "NVHHZTVGLVMXLWV"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace uppercase decoding.", correctOutput, output); - //Test whitespace decoding - input = "zyx wvu"; - correctOutput = "abcdef"; - output = cipher.decode(input); + inputString = "nvhhztv gl vmxlwv"; + correctOutput = "messagetoencode"; + output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace whitespace decoding.", correctOutput, output); - //Test symbol decoding - input = "zyx-wvu@"; - correctOutput = "abc-def@"; - output = cipher.decode(input); + inputString = "nvhhztv*gl+vmxlwv"; + correctOutput = "message*to+encode"; + output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace symbol decoding.", correctOutput, output); - //Test mixed case, whitespace, and symbol decoding - input = "Gsv jfrxp yildm ulc qfnkh levi - gsv ozab wlt"; - correctOutput = "Thequickbrownfoxjumpsover-thelazydog"; - output = cipher.decode(input); + inputString = "Nvhhztv gl^vmxlwv"; + correctOutput = "Messageto^encode"; + output = cipher.encode(inputString); assertEquals("Atbash failed no whitespace mixed case, whitespace, and symbol decoding.", correctOutput, output); } + @Test public void testNoSymbolDecode() throws InvalidInputException{ Atbash cipher = new Atbash(true, true, false); //Test lowercase decoding - String input = "zyx"; - String correctOutput = "abc"; - String output = cipher.decode(input); + String inputString = "nvhhztvglvmxlwv"; + String correctOutput = "messagetoencode"; + String output = cipher.encode(inputString); assertEquals("Atbash failed no symbol lowercase decoding.", correctOutput, output); //Test uppercase decoding - input = "ZYX"; - correctOutput = "ABC"; - output = cipher.decode(input); + inputString = "NVHHZTVGLVMXLWV"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed no symbol uppercase decoding.", correctOutput, output); - //Test whitespace decoding - input = "zyx wvu"; - correctOutput = "abc def"; - output = cipher.decode(input); + inputString = "nvhhztv gl vmxlwv"; + correctOutput = "message to encode"; + output = cipher.encode(inputString); assertEquals("Atbash failed no symbol whitespace decoding.", correctOutput, output); - //Test symbol decoding - input = "zyx-wvu@"; - correctOutput = "abcdef"; - output = cipher.decode(input); + inputString = "nvhhztv*gl+vmxlwv"; + correctOutput = "messagetoencode"; + output = cipher.encode(inputString); assertEquals("Atbash failed no symbol symbol decoding.", correctOutput, output); - //Test mixed case, whitespace, and symbol decoding - input = "Gsv jfrxp yildm ulc qfnkh levi - gsv ozab wlt"; - correctOutput = "The quick brown fox jumps over the lazy dog"; - output = cipher.decode(input); + inputString = "Nvhhztv gl^vmxlwv"; + correctOutput = "Message toencode"; + output = cipher.encode(inputString); assertEquals("Atbash failed no symbol mixed case, whitespace, and symbol decoding.", correctOutput, output); } + @Test - public void testNoCapitalwhitesapceSymbolDecode() throws InvalidInputException{ + public void testNoCapitalWhitespaceSymbolDecode() throws InvalidInputException{ Atbash cipher = new Atbash(false, false, false); //Test lowercase decoding - String input = "zyx"; - String correctOutput = "abc"; - String output = cipher.decode(input); + String inputString = "nvhhztvglvmxlwv"; + String correctOutput = "MESSAGETOENCODE"; + String output = cipher.encode(inputString); assertEquals("Atbash failed secure lowercase decoding.", correctOutput, output); //Test uppercase decoding - input = "ZYX"; - correctOutput = "abc"; - output = cipher.decode(input); + inputString = "NVHHZTVGLVMXLWV"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed secure uppercase decoding.", correctOutput, output); - //Test whitespace decoding - input = "zyx wvu"; - correctOutput = "abcdef"; - output = cipher.decode(input); + inputString = "nvhhztv gl vmxlwv"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed secure whitespace decoding.", correctOutput, output); - //Test symbol decoding - input = "zyx-wvu@"; - correctOutput = "abcdef"; - output = cipher.decode(input); + inputString = "nvhhztv*gl+vmxlwv"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed secure symbol decoding.", correctOutput, output); - //Test mixed case, whitespace, and symbol decoding - input = "Gsv jfrxp yildm ulc qfnkh levi - gsv ozab wlt"; - correctOutput = "thequickbrownfoxjumpsoverthelazydog"; - output = cipher.decode(input); + inputString = "Nvhhztv gl^vmxlwv"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.encode(inputString); assertEquals("Atbash failed secure mixed case, whitespace, and symbol decoding.", correctOutput, output); } }