Updated test message

This commit is contained in:
2021-07-25 16:59:32 -04:00
parent 4f8b440c59
commit 23c58a6fdc
2 changed files with 10 additions and 9 deletions

View File

@@ -7,9 +7,9 @@ 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
public static final String version = "1.0"; //The current version number for the library
private int shift; //The amount that you need to shift each letter private int shift; //The amount that you need to shift each letter
//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){

View File

@@ -14,32 +14,33 @@ import org.junit.Test;
public class TestCaesar{ public class TestCaesar{
@Test @Test
public void testDecode(){ public void testDecode(){
//Test 1
Caesar cipher = new Caesar(); Caesar cipher = new Caesar();
//Test 1
String input = "def"; String input = "def";
int shift = 3; int shift = 3;
String correctOutput = "abc"; String correctOutput = "abc";
String output = cipher.decode(shift, input); String output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the first test - Expected: " + correctOutput + "; actual: " + output, correctOutput, output); assertEquals("Caesar Decoding failed the first test", correctOutput, output);
//Test 2 //Test 2
input = "def"; input = "def";
shift = 29; shift = 29;
correctOutput = "abc"; correctOutput = "abc";
output = cipher.decode(shift, input); output = cipher.decode(shift, input);
assertEquals("Caesar Decoding failed the second test - Expected: " + correctOutput + "; actual: " + output, correctOutput, output); assertEquals("Caesar Decoding failed the second test", correctOutput, output);
//Test 3 //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 third test - Expected: " + correctOutput + "; actual: " + output, correctOutput, output); assertEquals("Caesar Decoding failed the third test", correctOutput, output);
//Test 4 //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 fourth test - Expected: " + correctOutput + "; actual: " + output, correctOutput, output); assertEquals("Caesar Decoding failed the fourth test", correctOutput, output);
} }
@Test @Test
public void testEncode(){ public void testEncode(){
@@ -49,7 +50,7 @@ public class TestCaesar{
int shift = 3; int shift = 3;
String correctOutput = "def"; String correctOutput = "def";
String output = cipher.encode(shift, input); String output = cipher.encode(shift, input);
assertEquals("Caesar Encoding failed the first test - Expected: " + correctOutput + "; actual: " + output, correctOutput, output); assertEquals("Caesar Encoding failed the first test", correctOutput, output);
//Test 2 //Test 2
input = "abc"; input = "abc";
shift = 29; shift = 29;
@@ -62,12 +63,12 @@ public class TestCaesar{
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 third test - Expected: " + correctOutput + "; actual: " + output, correctOutput, output); assertEquals("Caesar Encoding failed the third test", correctOutput, output);
//Test 4 //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 third test - Expected: " + correctOutput + "; actual: " + output, correctOutput, output); assertEquals("Caesar Encoding failed the third test", correctOutput, output);
} }
} }