Added encryption options
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestAtbash.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 07-25-21
|
||||
//Modified: 12-25-21
|
||||
//These are the tests for the Atbash class
|
||||
package mattrixwv.CipherStreamJava;
|
||||
|
||||
@@ -14,34 +14,364 @@ import org.junit.Test;
|
||||
public class TestAtbash{
|
||||
@Test
|
||||
public void testDecode(){
|
||||
Atbash cipher = new Atbash();
|
||||
Atbash cipher = new Atbash(true, true, true);
|
||||
|
||||
//Test 1
|
||||
//Test lowercase decoding
|
||||
String input = "zyx";
|
||||
String correctOutput = "ABC";
|
||||
String correctOutput = "abc";
|
||||
String output = cipher.decode(input);
|
||||
assertEquals("Atbash Decoding failed the first test", correctOutput, output);
|
||||
|
||||
//Test 2
|
||||
input = "GSV JFRXP YILDM ULC QFNKH LEVI - GSV OZAB WLT";
|
||||
correctOutput = "THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG";
|
||||
assertEquals("Atbash failed lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "ZYX";
|
||||
correctOutput = "ABC";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash Decoding failed the second test", correctOutput, output);
|
||||
assertEquals("Atbash failed uppercase decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "zyx wvu";
|
||||
correctOutput = "abc def";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash failed whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "zyx-wvu@";
|
||||
correctOutput = "abc-def@";
|
||||
output = cipher.decode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceDecode(){
|
||||
Atbash cipher = new Atbash(true, false, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
String input = "zyx";
|
||||
String correctOutput = "abc";
|
||||
String output = cipher.decode(input);
|
||||
assertEquals("Atbash failed no whitespace lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "ZYX";
|
||||
correctOutput = "ABC";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash failed no whitespace uppercase decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "zyx wvu";
|
||||
correctOutput = "abcdef";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash failed no whitespace whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "zyx-wvu@";
|
||||
correctOutput = "abc-def@";
|
||||
output = cipher.decode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed no whitespace mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalDecode(){
|
||||
Atbash cipher = new Atbash(false, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
String input = "zyx";
|
||||
String correctOutput = "abc";
|
||||
String output = cipher.decode(input);
|
||||
assertEquals("Atbash failed no capital lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "ZYX";
|
||||
correctOutput = "abc";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash failed no capital uppercase decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "zyx wvu";
|
||||
correctOutput = "abc def";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash failed no capital whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "zyx-wvu@";
|
||||
correctOutput = "abc-def@";
|
||||
output = cipher.decode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed no capital mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolDecode(){
|
||||
Atbash cipher = new Atbash(true, true, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
String input = "zyx";
|
||||
String correctOutput = "abc";
|
||||
String output = cipher.decode(input);
|
||||
assertEquals("Atbash failed no symbol lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "ZYX";
|
||||
correctOutput = "ABC";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash failed no symbol uppercase decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "zyx wvu";
|
||||
correctOutput = "abc def";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash failed no symbol whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "zyx-wvu@";
|
||||
correctOutput = "abcdef";
|
||||
output = cipher.decode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed no symbol mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalwhitesapceSymbolDecode(){
|
||||
Atbash cipher = new Atbash(false, false, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
String input = "zyx";
|
||||
String correctOutput = "abc";
|
||||
String output = cipher.decode(input);
|
||||
assertEquals("Atbash failed secure lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "ZYX";
|
||||
correctOutput = "abc";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash failed secure uppercase decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "zyx wvu";
|
||||
correctOutput = "abcdef";
|
||||
output = cipher.decode(input);
|
||||
assertEquals("Atbash failed secure whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "zyx-wvu@";
|
||||
correctOutput = "abcdef";
|
||||
output = cipher.decode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed secure mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncode(){
|
||||
Atbash cipher = new Atbash();
|
||||
Atbash cipher = new Atbash(true, true, true);
|
||||
|
||||
//Test 1
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String correctOutput = "ZYX";
|
||||
String correctOutput = "zyx";
|
||||
String output = cipher.encode(input);
|
||||
assertEquals("Atbash Encoding failed the first test", correctOutput, output);
|
||||
|
||||
//Test 2
|
||||
input = "The quick brown fox jumps over - the lazy dog";
|
||||
correctOutput = "GSVJFRXPYILDMULCQFNKHLEVIGSVOZABWLT";
|
||||
assertEquals("Atbash failed lowercase encoding.", correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
input = "ABC";
|
||||
correctOutput = "ZYX";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash Encoding failed the second test", correctOutput, output);
|
||||
assertEquals("Atbash failed uppercase encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "abc def";
|
||||
correctOutput = "zyx wvu";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash failed whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "abc-def@";
|
||||
correctOutput = "zyx-wvu@";
|
||||
output = cipher.encode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceEncode(){
|
||||
Atbash cipher = new Atbash(true, false, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String correctOutput = "zyx";
|
||||
String output = cipher.encode(input);
|
||||
assertEquals("Atbash failed no whitespace lowercase encoding.", correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
input = "ABC";
|
||||
correctOutput = "ZYX";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash failed no whitespace uppercase encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "abc def";
|
||||
correctOutput = "zyxwvu";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash failed no whitespace whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "abc-def@";
|
||||
correctOutput = "zyx-wvu@";
|
||||
output = cipher.encode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed no whitespace mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalEncode(){
|
||||
Atbash cipher = new Atbash(false, true, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String correctOutput = "zyx";
|
||||
String output = cipher.encode(input);
|
||||
assertEquals("Atbash failed no capital lowercase encoding.", correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
input = "ABC";
|
||||
correctOutput = "zyx";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash failed no capital uppercase encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "abc def";
|
||||
correctOutput = "zyx wvu";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash failed no capital whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "abc-def@";
|
||||
correctOutput = "zyx-wvu@";
|
||||
output = cipher.encode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed no capital mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolEncode(){
|
||||
Atbash cipher = new Atbash(true, true, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String correctOutput = "zyx";
|
||||
String output = cipher.encode(input);
|
||||
assertEquals("Atbash failed no symbol lowercase encoding.", correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
input = "ABC";
|
||||
correctOutput = "ZYX";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash failed no symbol uppercase encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "abc def";
|
||||
correctOutput = "zyx wvu";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash failed no symbol whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "abc-def@";
|
||||
correctOutput = "zyxwvu";
|
||||
output = cipher.encode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed no symbol mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolEncode(){
|
||||
Atbash cipher = new Atbash(false, false, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String correctOutput = "zyx";
|
||||
String output = cipher.encode(input);
|
||||
assertEquals("Atbash failed secure lowercase encoding.", correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
input = "ABC";
|
||||
correctOutput = "zyx";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash failed secure uppercase encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "abc def";
|
||||
correctOutput = "zyxwvu";
|
||||
output = cipher.encode(input);
|
||||
assertEquals("Atbash failed secure whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "abc-def@";
|
||||
correctOutput = "zyxwvu";
|
||||
output = cipher.encode(input);
|
||||
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);
|
||||
assertEquals("Atbash failed secure mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user