Merge
This commit is contained in:
@@ -1,16 +1,15 @@
|
|||||||
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/Atbash.java
|
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/Atbash.java
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 07-25-21
|
// Created: 07-25-21
|
||||||
//Modified: 12-25-21
|
//Modified: 07-25-21
|
||||||
//This is the declaration of the Atbash class
|
//This is the declaration of the Atbash class
|
||||||
package mattrixwv.CipherStreamJava;
|
package mattrixwv.CipherStreamJava;
|
||||||
|
|
||||||
|
|
||||||
public class Atbash{
|
public class Atbash{
|
||||||
|
public static final String version = "1.0";
|
||||||
private String inputString; //Holds the string that needs encoded or decoded
|
private String inputString; //Holds the string that needs encoded or decoded
|
||||||
private String outputString; //The encoded/decoded string
|
private String outputString; //Holds teh current version of the library
|
||||||
private boolean leaveCapitals; //Whether to respect capitals in the output string
|
|
||||||
private boolean leaveWhitespace; //Whether to respect whitespace in the output string
|
|
||||||
//Decodes inputString and stores in outputString
|
//Decodes inputString and stores in outputString
|
||||||
private String decode(){
|
private String decode(){
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
@@ -27,16 +26,7 @@ public class Atbash{
|
|||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
//Step through every element in the inputString and shift it the correct amount
|
//Step through every element in the inputString and shift it the correct amount
|
||||||
for(int cnt = 0;cnt < inputString.length();++cnt){
|
for(int cnt = 0;cnt < inputString.length();++cnt){
|
||||||
//Skip any whitespace
|
output.append((char)(inputString.charAt(cnt) + 25 - (2 * (inputString.charAt(cnt) - 'A'))));
|
||||||
if(Character.isWhitespace(inputString.charAt(cnt))){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//Use either uppercase or lowercase for the base
|
|
||||||
char letterBase = 'a';
|
|
||||||
if(Character.isUpperCase(inputString.charAt(cnt))){
|
|
||||||
letterBase = 'A';
|
|
||||||
}
|
|
||||||
output.append((char)(inputString.charAt(cnt) + 25 - (2 * (inputString.charAt(cnt) - letterBase))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outputString = output.toString();
|
outputString = output.toString();
|
||||||
@@ -44,29 +34,15 @@ public class Atbash{
|
|||||||
}
|
}
|
||||||
//Removes all invalid characters and sets inputString
|
//Removes all invalid characters and sets inputString
|
||||||
private void setInputString(String input){
|
private void setInputString(String input){
|
||||||
if(!leaveCapitals){
|
|
||||||
//Convert all letters to uppercase
|
//Convert all letters to uppercase
|
||||||
input = input.toUpperCase();
|
input = input.toUpperCase();
|
||||||
}
|
|
||||||
if(!leaveWhitespace){
|
|
||||||
//Remove all characters except capital letters
|
//Remove all characters except capital letters
|
||||||
input = input.toLowerCase();
|
input = input.replaceAll("[^A-Z]", "");
|
||||||
}
|
|
||||||
//Save the string
|
//Save the string
|
||||||
inputString = input;
|
inputString = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Atbash(){
|
|
||||||
reset();
|
|
||||||
leaveCapitals = false;
|
|
||||||
leaveWhitespace = false;
|
|
||||||
}
|
|
||||||
public Atbash(boolean leaveCapitals, boolean leaveWhitespace){
|
|
||||||
reset();
|
|
||||||
this.leaveCapitals = leaveCapitals;
|
|
||||||
this.leaveWhitespace = leaveWhitespace;
|
|
||||||
}
|
|
||||||
public String getInputString(){
|
public String getInputString(){
|
||||||
return inputString;
|
return inputString;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/Caesar.java
|
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/Caesar.java
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 07-25-21
|
// Created: 07-25-21
|
||||||
//Modified: 12-25-21
|
//Modified: 07-25-21
|
||||||
//This is the declaration of the Caesar class
|
//This is the declaration of the Caesar class
|
||||||
package mattrixwv.CipherStreamJava;
|
package mattrixwv.CipherStreamJava;
|
||||||
|
|
||||||
|
|
||||||
public class Caesar{
|
public class Caesar{
|
||||||
|
public static final String version = "1.0"; //The current version number for the library
|
||||||
private String inputString; //The string that needs encoded/decoded
|
private String inputString; //The string that needs encoded/decoded
|
||||||
private String outputString; //The encoded/decoded string
|
private String outputString; //The encoded/decoded string
|
||||||
private int shift; //The amount that you need to shift each letter
|
private int shift; //The amount that you need to shift each letter
|
||||||
private boolean leaveCapitals; //Whether to respect capitals in the output string
|
|
||||||
private boolean leaveWhitespace; //Whether to respect whitespace in the output string
|
|
||||||
//Sets shift and makes sure it is within the propper bounds
|
//Sets shift and makes sure it is within the propper bounds
|
||||||
private void setShift(int shiftAmount){
|
private void setShift(int shiftAmount){
|
||||||
//If you shift more than 26 you will just be wrapping back around again
|
//If you shift more than 26 you will just be wrapping back around again
|
||||||
@@ -19,12 +18,6 @@ public class Caesar{
|
|||||||
}
|
}
|
||||||
//Sets the input string
|
//Sets the input string
|
||||||
private void setInputString(String inputString){
|
private void setInputString(String inputString){
|
||||||
if(!leaveCapitals){
|
|
||||||
inputString = inputString.toLowerCase();
|
|
||||||
}
|
|
||||||
if(!leaveWhitespace){
|
|
||||||
inputString = inputString.replaceAll("\\s+", "");
|
|
||||||
}
|
|
||||||
this.inputString = inputString;
|
this.inputString = inputString;
|
||||||
}
|
}
|
||||||
//Encodes the inputString and stores the result in outputString
|
//Encodes the inputString and stores the result in outputString
|
||||||
@@ -99,13 +92,6 @@ public class Caesar{
|
|||||||
//Constructor
|
//Constructor
|
||||||
public Caesar(){
|
public Caesar(){
|
||||||
reset();
|
reset();
|
||||||
leaveCapitals = false;
|
|
||||||
leaveWhitespace = false;
|
|
||||||
}
|
|
||||||
public Caesar(boolean leaveCapitals, boolean leaveWhitespace){
|
|
||||||
reset();
|
|
||||||
this.leaveCapitals = leaveCapitals;
|
|
||||||
this.leaveWhitespace = leaveWhitespace;
|
|
||||||
}
|
}
|
||||||
//Returns the inputString
|
//Returns the inputString
|
||||||
public String getInputString(){
|
public String getInputString(){
|
||||||
@@ -119,20 +105,6 @@ public class Caesar{
|
|||||||
public String getOutputString(){
|
public String getOutputString(){
|
||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
//Returns if capitals should be respected in the output
|
|
||||||
public boolean getLeaveCapitals(){
|
|
||||||
return leaveCapitals;
|
|
||||||
}
|
|
||||||
public void setLeaveCapitals(boolean leaveCapitals){
|
|
||||||
this.leaveCapitals = leaveCapitals;
|
|
||||||
}
|
|
||||||
//Returns if whitespace should be respected in the output
|
|
||||||
public boolean getLeaveWhitespace(){
|
|
||||||
return leaveWhitespace;
|
|
||||||
}
|
|
||||||
public void setLeaveWhitespace(boolean leaveWhitespace){
|
|
||||||
this.leaveWhitespace = leaveWhitespace;
|
|
||||||
}
|
|
||||||
//Sets the shift and inputString and encodes the message
|
//Sets the shift and inputString and encodes the message
|
||||||
public String encode(int shiftAmount, String inputString){
|
public String encode(int shiftAmount, String inputString){
|
||||||
reset();
|
reset();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/Morse.java
|
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/Morse.java
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 07-26-21
|
// Created: 07-28-21
|
||||||
//Modified: 07-26-21
|
//Modified: 07-28-21
|
||||||
//This is the declaration of the Morse class
|
//This is the declaration of the Morse class
|
||||||
package mattrixwv.CipherStreamJava;
|
package mattrixwv.CipherStreamJava;
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@ public class Morse{
|
|||||||
"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", //M-Z
|
"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", //M-Z
|
||||||
"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----." //0-9
|
"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----." //0-9
|
||||||
};
|
};
|
||||||
|
public static final String version = "1.0"; //The current library's version
|
||||||
private String inputString; //The string that needs encoded/decoded
|
private String inputString; //The string that needs encoded/decoded
|
||||||
private String outputString; //The encoded/decoded message
|
private String outputString; //The encoded/decoded message
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package mattrixwv.CipherStreamJava;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Vigenere{
|
public class Vigenere{
|
||||||
|
public static final String version = "1.0"; //The current library's version number
|
||||||
protected String inputString; //This is the string that needs encoded/decoded
|
protected String inputString; //This is the string that needs encoded/decoded
|
||||||
protected String outputString; //This is the string that is output after encoding/decoding
|
protected String outputString; //This is the string that is output after encoding/decoding
|
||||||
protected String keyword; //This is the keyword that is resposible for determining the offsets that you change each character by
|
protected String keyword; //This is the keyword that is resposible for determining the offsets that you change each character by
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestAtbash.java
|
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestAtbash.java
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 07-25-21
|
// Created: 07-25-21
|
||||||
//Modified: 12-25-21
|
//Modified: 07-25-21
|
||||||
//These are the tests for the Atbash class
|
//These are the tests for the Atbash class
|
||||||
package mattrixwv.CipherStreamJava;
|
package mattrixwv.CipherStreamJava;
|
||||||
|
|
||||||
@@ -18,13 +18,13 @@ public class TestAtbash{
|
|||||||
|
|
||||||
//Test 1
|
//Test 1
|
||||||
String input = "zyx";
|
String input = "zyx";
|
||||||
String correctOutput = "abc";
|
String correctOutput = "ABC";
|
||||||
String output = cipher.decode(input);
|
String output = cipher.decode(input);
|
||||||
assertEquals("Atbash Decoding failed the first test", correctOutput, output);
|
assertEquals("Atbash Decoding failed the first test", correctOutput, output);
|
||||||
|
|
||||||
//Test 2
|
//Test 2
|
||||||
input = "GSV JFRXP YILDM ULC QFNKH LEVI - GSV OZAB WLT";
|
input = "GSV JFRXP YILDM ULC QFNKH LEVI - GSV OZAB WLT";
|
||||||
correctOutput = "thequickbrownfoxjumpsoverthelazydog";
|
correctOutput = "THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG";
|
||||||
output = cipher.decode(input);
|
output = cipher.decode(input);
|
||||||
assertEquals("Atbash Decoding failed the second test", correctOutput, output);
|
assertEquals("Atbash Decoding failed the second test", correctOutput, output);
|
||||||
}
|
}
|
||||||
@@ -34,13 +34,13 @@ public class TestAtbash{
|
|||||||
|
|
||||||
//Test 1
|
//Test 1
|
||||||
String input = "abc";
|
String input = "abc";
|
||||||
String correctOutput = "zyx";
|
String correctOutput = "ZYX";
|
||||||
String output = cipher.encode(input);
|
String output = cipher.encode(input);
|
||||||
assertEquals("Atbash Encoding failed the first test", correctOutput, output);
|
assertEquals("Atbash Encoding failed the first test", correctOutput, output);
|
||||||
|
|
||||||
//Test 2
|
//Test 2
|
||||||
input = "The quick brown fox jumps over - the lazy dog";
|
input = "The quick brown fox jumps over - the lazy dog";
|
||||||
correctOutput = "gsvjfrxpyildmulcqfnkhlevigsvozabwlt";
|
correctOutput = "GSVJFRXPYILDMULCQFNKHLEVIGSVOZABWLT";
|
||||||
output = cipher.encode(input);
|
output = cipher.encode(input);
|
||||||
assertEquals("Atbash Encoding failed the second test", correctOutput, output);
|
assertEquals("Atbash Encoding failed the second test", correctOutput, output);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//CipherStreamJava/src/test/java/mattrixwv/CipherStreamJava/TestCaesar.java
|
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestCaesar.java
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 07-25-21
|
// Created: 07-25-21
|
||||||
//Modified: 12-25-21
|
//Modified: 07-25-21
|
||||||
//These are the tests for the Caesar class
|
//These are the tests for the Caesar class
|
||||||
package mattrixwv.CipherStreamJava;
|
package mattrixwv.CipherStreamJava;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ import org.junit.Test;
|
|||||||
public class TestCaesar{
|
public class TestCaesar{
|
||||||
@Test
|
@Test
|
||||||
public void testDecode(){
|
public void testDecode(){
|
||||||
Caesar cipher = new Caesar(true, true);
|
Caesar cipher = new Caesar();
|
||||||
|
|
||||||
//Test 1
|
//Test 1
|
||||||
String input = "def";
|
String input = "def";
|
||||||
@@ -28,139 +28,24 @@ public class TestCaesar{
|
|||||||
correctOutput = "abc";
|
correctOutput = "abc";
|
||||||
output = cipher.decode(shift, input);
|
output = cipher.decode(shift, input);
|
||||||
assertEquals("Caesar Decoding failed the second test", correctOutput, output);
|
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";
|
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
||||||
shift = -3;
|
shift = -3;
|
||||||
correctOutput = "The quick brown fox jumps over - the lazy dog";
|
correctOutput = "The quick brown fox jumps over - the lazy dog";
|
||||||
output = cipher.decode(shift, input);
|
output = cipher.decode(shift, input);
|
||||||
assertEquals("Caesar Decoding failed the fourth test", correctOutput, output);
|
assertEquals("Caesar Decoding failed the third test", correctOutput, output);
|
||||||
//Test 5
|
//Test 4
|
||||||
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
input = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
||||||
shift = 23;
|
shift = 23;
|
||||||
correctOutput = "The quick brown fox jumps over - the lazy dog";
|
correctOutput = "The quick brown fox jumps over - the lazy dog";
|
||||||
output = cipher.decode(shift, input);
|
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);
|
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
|
@Test
|
||||||
public void testEncode(){
|
public void testEncode(){
|
||||||
//Test 1
|
//Test 1
|
||||||
Caesar cipher = new Caesar(true, true);
|
Caesar cipher = new Caesar();
|
||||||
String input = "abc";
|
String input = "abc";
|
||||||
int shift = 3;
|
int shift = 3;
|
||||||
String correctOutput = "def";
|
String correctOutput = "def";
|
||||||
@@ -171,130 +56,19 @@ public class TestCaesar{
|
|||||||
shift = 29;
|
shift = 29;
|
||||||
correctOutput = "def";
|
correctOutput = "def";
|
||||||
output = cipher.encode(shift, input);
|
output = cipher.encode(shift, input);
|
||||||
assertEquals("Caesar Encoding failed the second test", correctOutput, output);
|
assertEquals("Caesar Encoding failed the second test - Expected: " + correctOutput + "; actual" + output, 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
|
//Test 3
|
||||||
input = "The quick brown fox jumps over - the lazy dog";
|
input = "The quick brown fox jumps over - the lazy dog";
|
||||||
shift = -3;
|
shift = -3;
|
||||||
correctOutput = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
correctOutput = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
||||||
output = cipher.encode(shift, input);
|
output = cipher.encode(shift, input);
|
||||||
assertEquals("Caesar Encoding failed the fourth test", correctOutput, output);
|
assertEquals("Caesar Encoding failed the third test", correctOutput, output);
|
||||||
//Test 5
|
//Test 4
|
||||||
input = "The quick brown fox jumps over - the lazy dog";
|
input = "The quick brown fox jumps over - the lazy dog";
|
||||||
shift = 23;
|
shift = 23;
|
||||||
correctOutput = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
correctOutput = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
||||||
output = cipher.encode(shift, input);
|
output = cipher.encode(shift, input);
|
||||||
assertEquals("Caesar Encoding failed the fifth test", correctOutput, output);
|
assertEquals("Caesar Encoding failed the third 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestVigenere.java
|
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestMorse.java
|
||||||
//Matthew Ellison
|
//Matthew Ellison
|
||||||
// Created: 07-25-21
|
// Created: 07-28-21
|
||||||
//Modified: 07-25-21
|
//Modified: 07-28-21
|
||||||
//These are the tests for the Vigenere class
|
//These are the tests for the Morse class
|
||||||
package mattrixwv.CipherStreamJava;
|
package mattrixwv.CipherStreamJava;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user