Added Vigenere cipher
This commit is contained in:
65
src/test/java/mattrixwv/CipherStreamJava/TestVigenere.java
Normal file
65
src/test/java/mattrixwv/CipherStreamJava/TestVigenere.java
Normal file
@@ -0,0 +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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user