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