This commit is contained in:
2021-12-30 16:07:16 -05:00
parent 11c06657a5
commit cf183c1bda
9 changed files with 248 additions and 524 deletions

View File

@@ -1,7 +1,7 @@
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestAtbash.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 12-25-21
//Modified: 07-25-21
//These are the tests for the Atbash class
package mattrixwv.CipherStreamJava;
@@ -18,13 +18,13 @@ public class TestAtbash{
//Test 1
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";
correctOutput = "THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG";
output = cipher.decode(input);
assertEquals("Atbash Decoding failed the second test", correctOutput, output);
}
@@ -34,13 +34,13 @@ public class TestAtbash{
//Test 1
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";
correctOutput = "GSVJFRXPYILDMULCQFNKHLEVIGSVOZABWLT";
output = cipher.encode(input);
assertEquals("Atbash Encoding failed the second test", correctOutput, output);
}

View File

@@ -1,7 +1,7 @@
//CipherStreamJava/src/test/java/mattrixwv/CipherStreamJava/TestCaesar.java
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestCaesar.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 12-25-21
//Modified: 07-25-21
//These are the tests for the Caesar class
package mattrixwv.CipherStreamJava;
@@ -14,7 +14,7 @@ import org.junit.Test;
public class TestCaesar{
@Test
public void testDecode(){
Caesar cipher = new Caesar(true, true);
Caesar cipher = new Caesar();
//Test 1
String input = "def";
@@ -28,139 +28,24 @@ public class TestCaesar{
correctOutput = "abc";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the second test", correctOutput, output);
//Test 3
input = "DEF";
shift = 3;
correctOutput = "ABC";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the third test", correctOutput, output);
//Test 4
//Test 3
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
shift = -3;
correctOutput = "The quick brown fox jumps over - the lazy dog";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the fourth test", correctOutput, output);
//Test 5
assertEquals("Caesar Decoding failed the third test", correctOutput, output);
//Test 4
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
shift = 23;
correctOutput = "The quick brown fox jumps over - the lazy dog";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the fifth test", correctOutput, output);
}
@Test
public void testNoWhitespaceDecode(){
Caesar cipher = new Caesar(true, false);
//Test 1
String input = "def";
int shift = 3;
String correctOutput = "abc";
String output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the first test", correctOutput, output);
//Test 2
input = "def";
shift = 29;
correctOutput = "abc";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the second test", correctOutput, output);
//Test 3
input = "DEF";
shift = 3;
correctOutput = "ABC";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the third test", correctOutput, output);
//Test 4
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
shift = -3;
correctOutput = "Thequickbrownfoxjumpsover-thelazydog";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the fourth test", correctOutput, output);
//Test 5
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
shift = 23;
correctOutput = "Thequickbrownfoxjumpsover-thelazydog";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the fifth test", correctOutput, output);
}
@Test
public void testNoCapitalDecode(){
Caesar cipher = new Caesar(false, true);
//Test 1
String input = "def";
int shift = 3;
String correctOutput = "abc";
String output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the first test", correctOutput, output);
//Test 2
input = "def";
shift = 29;
correctOutput = "abc";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the second test", correctOutput, output);
//Test 3
input = "DEF";
shift = 3;
correctOutput = "abc";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the third test", correctOutput, output);
//Test 4
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
shift = -3;
correctOutput = "the quick brown fox jumps over - the lazy dog";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the fourth test", correctOutput, output);
//Test 5
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
shift = 23;
correctOutput = "the quick brown fox jumps over - the lazy dog";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the fifth test", correctOutput, output);
}
@Test
public void testNoCapitalWhitespaceDecode(){
Caesar cipher = new Caesar(false, false);
//Test 1
String input = "def";
int shift = 3;
String correctOutput = "abc";
String output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the first test", correctOutput, output);
//Test 2
input = "def";
shift = 29;
correctOutput = "abc";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the second test", correctOutput, output);
//Test 3
input = "DEF";
shift = 3;
correctOutput = "abc";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the third test", correctOutput, output);
//Test 4
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
shift = -3;
correctOutput = "thequickbrownfoxjumpsover-thelazydog";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the fourth test", correctOutput, output);
//Test 5
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
shift = 23;
correctOutput = "thequickbrownfoxjumpsover-thelazydog";
output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the fifth test", correctOutput, output);
}
@Test
public void testEncode(){
//Test 1
Caesar cipher = new Caesar(true, true);
Caesar cipher = new Caesar();
String input = "abc";
int shift = 3;
String correctOutput = "def";
@@ -171,130 +56,19 @@ public class TestCaesar{
shift = 29;
correctOutput = "def";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the second test", correctOutput, output);
//Test 3
input = "ABC";
shift = 3;
correctOutput = "DEF";
output = cipher.encode(shift, input);
assertEquals("Ceasar Encoding failed the third test", correctOutput, output);
assertEquals("Caesar Encoding failed the second test - Expected: " + correctOutput + "; actual" + output, correctOutput, output);
//Test 4
//Test 3
input = "The quick brown fox jumps over - the lazy dog";
shift = -3;
correctOutput = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the fourth test", correctOutput, output);
//Test 5
assertEquals("Caesar Encoding failed the third test", correctOutput, output);
//Test 4
input = "The quick brown fox jumps over - the lazy dog";
shift = 23;
correctOutput = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the fifth test", correctOutput, output);
}
@Test
public void testNoWhitespaceEncode(){
//Test 1
Caesar cipher = new Caesar(true, false);
String input = "abc";
int shift = 3;
String correctOutput = "def";
String output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the first test", correctOutput, output);
//Test 2
input = "abc";
shift = 29;
correctOutput = "def";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the second test", correctOutput, output);
//Test 3
input = "ABC";
shift = 3;
correctOutput = "DEF";
output = cipher.encode(shift, input);
assertEquals("Ceasar Encoding failed the third test", correctOutput, output);
//Test 4
input = "The quick brown fox jumps over - the lazy dog";
shift = -3;
correctOutput = "Qebnrfzhyoltkclugrjmplsbo-qebixwvald";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the fourth test", correctOutput, output);
//Test 5
input = "The quick brown fox jumps over - the lazy dog";
shift = 23;
correctOutput = "Qebnrfzhyoltkclugrjmplsbo-qebixwvald";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the fifth test", correctOutput, output);
}
@Test
public void testNoCapitalEncode(){
//Test 1
Caesar cipher = new Caesar(false, true);
String input = "abc";
int shift = 3;
String correctOutput = "def";
String output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the first test", correctOutput, output);
//Test 2
input = "abc";
shift = 29;
correctOutput = "def";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the second test", correctOutput, output);
//Test 3
input = "ABC";
shift = 3;
correctOutput = "def";
output = cipher.encode(shift, input);
assertEquals("Ceasar Encoding failed the third test", correctOutput, output);
//Test 4
input = "The quick brown fox jumps over - the lazy dog";
shift = -3;
correctOutput = "qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the fourth test", correctOutput, output);
//Test 5
input = "The quick brown fox jumps over - the lazy dog";
shift = 23;
correctOutput = "qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the fifth test", correctOutput, output);
}
@Test
public void testNoCapitalWhitespaceEncode(){
//Test 1
Caesar cipher = new Caesar(false, false);
String input = "abc";
int shift = 3;
String correctOutput = "def";
String output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the first test", correctOutput, output);
//Test 2
input = "abc";
shift = 29;
correctOutput = "def";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the second test", correctOutput, output);
//Test 3
input = "ABC";
shift = 3;
correctOutput = "def";
output = cipher.encode(shift, input);
assertEquals("Ceasar Encoding failed the third test", correctOutput, output);
//Test 4
input = "The quick brown fox jumps over - the lazy dog";
shift = -3;
correctOutput = "qebnrfzhyoltkclugrjmplsbo-qebixwvald";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the fourth test", correctOutput, output);
//Test 5
input = "The quick brown fox jumps over - the lazy dog";
shift = 23;
correctOutput = "qebnrfzhyoltkclugrjmplsbo-qebixwvald";
output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the fifth test", correctOutput, output);
assertEquals("Caesar Encoding failed the third test", correctOutput, output);
}
}

View File

@@ -1,59 +1,59 @@
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestVigenere.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 07-25-21
//These are the tests for the Vigenere class
package mattrixwv.CipherStreamJava;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TestMorse{
@Test
public void testDecode(){
Morse cipher = new Morse();
//Test 1
String input = "... --- ...";
String correctOutput = "SOS";
String output = cipher.decode(input);
assertEquals("Morse Decoding failed the first test", correctOutput, output);
//Test 2
input = "-- --- .-. ... . -.-. --- -.. .";
correctOutput = "MORSECODE";
output = cipher.decode(input);
assertEquals("Morse Decoding failed the second test", correctOutput, output);
//Test 3
input = ".---- ..--- ...-- ----. ---.. --...";
correctOutput = "123987";
output = cipher.decode(input);
assertEquals("Morse Decoding failed the third test", correctOutput, output);
}
@Test
public void testEncode(){
Morse cipher = new Morse();
//Test 1
String input = "sos";
String correctOutput = "... --- ...";
String output = cipher.encode(input);
assertEquals("Morse Encoding failed the first test", correctOutput, output);
//Test 2
input = "MORSE, CODE";
correctOutput = "-- --- .-. ... . -.-. --- -.. .";
output = cipher.encode(input);
assertEquals("Morse Encoding failed the second test", correctOutput, output);
//Test 3
input = "1.23 987";
correctOutput = ".---- ..--- ...-- ----. ---.. --...";
output = cipher.encode(input);
assertEquals("Morse Encoding failed the third test", correctOutput, output);
}
}
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestMorse.java
//Matthew Ellison
// Created: 07-28-21
//Modified: 07-28-21
//These are the tests for the Morse class
package mattrixwv.CipherStreamJava;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TestMorse{
@Test
public void testDecode(){
Morse cipher = new Morse();
//Test 1
String input = "... --- ...";
String correctOutput = "SOS";
String output = cipher.decode(input);
assertEquals("Morse Decoding failed the first test", correctOutput, output);
//Test 2
input = "-- --- .-. ... . -.-. --- -.. .";
correctOutput = "MORSECODE";
output = cipher.decode(input);
assertEquals("Morse Decoding failed the second test", correctOutput, output);
//Test 3
input = ".---- ..--- ...-- ----. ---.. --...";
correctOutput = "123987";
output = cipher.decode(input);
assertEquals("Morse Decoding failed the third test", correctOutput, output);
}
@Test
public void testEncode(){
Morse cipher = new Morse();
//Test 1
String input = "sos";
String correctOutput = "... --- ...";
String output = cipher.encode(input);
assertEquals("Morse Encoding failed the first test", correctOutput, output);
//Test 2
input = "MORSE, CODE";
correctOutput = "-- --- .-. ... . -.-. --- -.. .";
output = cipher.encode(input);
assertEquals("Morse Encoding failed the second test", correctOutput, output);
//Test 3
input = "1.23 987";
correctOutput = ".---- ..--- ...-- ----. ---.. --...";
output = cipher.encode(input);
assertEquals("Morse Encoding failed the third test", correctOutput, output);
}
}

View File

@@ -1,65 +1,65 @@
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestVigenere.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 07-25-21
//These are the tests for the Vigenere class
package mattrixwv.CipherStreamJava;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TestVigenere{
@Test
public void testDecode() throws Exception{
Vigenere cipher = new Vigenere();
//Test 1
String input = "xzb";
String keyword = "xyz";
String correctOutput = "ABC";
String output = cipher.decode(keyword, input);
assertEquals("Vigenere Decoding failed the first test", correctOutput, output);
//Test 2
input = "LXFOPVEFRNHR";
keyword = "LEMON";
correctOutput = "ATTACKATDAWN";
output = cipher.decode(keyword, input);
assertEquals("Vigenere Decoding failed the second test", correctOutput, output);
//Test 3
input = "CSASTPKVSIQUTGQUCSASTPIUAQJB";
keyword = "ABCD";
correctOutput = "CRYPTOISSHORTFORCRYPTOGRAPHY";
output = cipher.decode(keyword, input);
assertEquals("Vigenere Decoding failed the third test", correctOutput, output);
}
@Test
public void testEncode() throws Exception{
Vigenere cipher = new Vigenere();
//Test 1
String input = "abc";
String keyword = "xyz";
String correctOutput = "XZB";
String output = cipher.encode(keyword, input);
assertEquals("Vigenere Encoding failed the first test", correctOutput, output);
//Test 2
input = "Attack at dawn";
keyword = "Lemon";
correctOutput = "LXFOPVEFRNHR";
output = cipher.encode(keyword, input);
assertEquals("Vigenere Encoding failed the second test", correctOutput, output);
//Test 3
input = "'Crypto' is short for 'Cryptography'";
keyword = "abcd";
correctOutput = "CSASTPKVSIQUTGQUCSASTPIUAQJB";
output = cipher.encode(keyword, input);
assertEquals("Vigenere Encoding failed the third test", correctOutput, output);
}
}
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestVigenere.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 07-25-21
//These are the tests for the Vigenere class
package mattrixwv.CipherStreamJava;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TestVigenere{
@Test
public void testDecode() throws Exception{
Vigenere cipher = new Vigenere();
//Test 1
String input = "xzb";
String keyword = "xyz";
String correctOutput = "ABC";
String output = cipher.decode(keyword, input);
assertEquals("Vigenere Decoding failed the first test", correctOutput, output);
//Test 2
input = "LXFOPVEFRNHR";
keyword = "LEMON";
correctOutput = "ATTACKATDAWN";
output = cipher.decode(keyword, input);
assertEquals("Vigenere Decoding failed the second test", correctOutput, output);
//Test 3
input = "CSASTPKVSIQUTGQUCSASTPIUAQJB";
keyword = "ABCD";
correctOutput = "CRYPTOISSHORTFORCRYPTOGRAPHY";
output = cipher.decode(keyword, input);
assertEquals("Vigenere Decoding failed the third test", correctOutput, output);
}
@Test
public void testEncode() throws Exception{
Vigenere cipher = new Vigenere();
//Test 1
String input = "abc";
String keyword = "xyz";
String correctOutput = "XZB";
String output = cipher.encode(keyword, input);
assertEquals("Vigenere Encoding failed the first test", correctOutput, output);
//Test 2
input = "Attack at dawn";
keyword = "Lemon";
correctOutput = "LXFOPVEFRNHR";
output = cipher.encode(keyword, input);
assertEquals("Vigenere Encoding failed the second test", correctOutput, output);
//Test 3
input = "'Crypto' is short for 'Cryptography'";
keyword = "abcd";
correctOutput = "CSASTPKVSIQUTGQUCSASTPIUAQJB";
output = cipher.encode(keyword, input);
assertEquals("Vigenere Encoding failed the third test", correctOutput, output);
}
}