Added encoding options
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestVigenere.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 07-25-21
|
||||
//Modified: 12-30-21
|
||||
//These are the tests for the Vigenere class
|
||||
package mattrixwv.CipherStreamJava;
|
||||
|
||||
@@ -14,52 +14,510 @@ import org.junit.Test;
|
||||
public class TestVigenere{
|
||||
@Test
|
||||
public void testDecode() throws Exception{
|
||||
Vigenere cipher = new Vigenere();
|
||||
Vigenere cipher = new Vigenere(true, true, true);
|
||||
|
||||
//Test 1
|
||||
//Test lowercase decoding
|
||||
String input = "xzb";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "ABC";
|
||||
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";
|
||||
assertEquals("Vigenere failed lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "XZB";
|
||||
keyword = "XYZ";
|
||||
correctOutput = "ABC";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere Decoding failed the second test", correctOutput, output);
|
||||
assertEquals("Vigenere failed uppercase decoding.", correctOutput, output);
|
||||
|
||||
//Test 3
|
||||
input = "CSASTPKVSIQUTGQUCSASTPIUAQJB";
|
||||
keyword = "ABCD";
|
||||
correctOutput = "CRYPTOISSHORTFORCRYPTOGRAPHY";
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "x z b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "a b c";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere Decoding failed the third test", correctOutput, output);
|
||||
assertEquals("Vigenere failed whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "x@z^b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "a@b^c";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Lxfopv ef - rnhr";
|
||||
keyword = "lemon";
|
||||
correctOutput = "Attack at - dawn";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding with mangled keyword
|
||||
input = "'Csastp' kv siqut gqu 'Csastpiuaqjb'";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "'Crypto' is short for 'Cryptography'";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testEncode() throws Exception{
|
||||
Vigenere cipher = new Vigenere();
|
||||
public void testNoWhitespaceDecode() throws Exception{
|
||||
Vigenere cipher = new Vigenere(true, false, true);
|
||||
|
||||
//Test 1
|
||||
//Test lowercase decoding
|
||||
String input = "xzb";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "abc";
|
||||
String output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "XZB";
|
||||
keyword = "XYZ";
|
||||
correctOutput = "ABC";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed uppercase decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "x z b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "abc";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "x@z^b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "a@b^c";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Lxfopv ef - rnhr";
|
||||
keyword = "lemon";
|
||||
correctOutput = "Attackat-dawn";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding with mangled keyword
|
||||
input = "'Csastp' kv siqut gqu 'Csastpiuaqjb'";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "'Crypto'isshortfor'Cryptography'";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalDecode() throws Exception{
|
||||
Vigenere cipher = new Vigenere(false, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
String input = "xzb";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "abc";
|
||||
String output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "XZB";
|
||||
keyword = "XYZ";
|
||||
correctOutput = "abc";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed uppercase decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "x z b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "a b c";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "x@z^b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "a@b^c";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Lxfopv ef - rnhr";
|
||||
keyword = "lemon";
|
||||
correctOutput = "attack at - dawn";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding with mangled keyword
|
||||
input = "'Csastp' kv siqut gqu 'Csastpiuaqjb'";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "'crypto' is short for 'cryptography'";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolDecodes() throws Exception{
|
||||
Vigenere cipher = new Vigenere(true, true, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
String input = "xzb";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "abc";
|
||||
String output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "XZB";
|
||||
keyword = "XYZ";
|
||||
correctOutput = "ABC";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed uppercase decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "x z b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "a b c";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "x@z^b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "abc";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Lxfopv ef - rnhr";
|
||||
keyword = "lemon";
|
||||
correctOutput = "Attack at dawn";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding with mangled keyword
|
||||
input = "'Csastp' kv siqut gqu 'Csastpiuaqjb'";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "Crypto is short for Cryptography";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolDecode() throws Exception{
|
||||
Vigenere cipher = new Vigenere(false, false, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
String input = "xzb";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "abc";
|
||||
String output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed lowercase decoding.", correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
input = "XZB";
|
||||
keyword = "XYZ";
|
||||
correctOutput = "abc";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed uppercase decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace decoding
|
||||
input = "x z b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "abc";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed whitespace decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "x@z^b";
|
||||
keyword = "xyz";
|
||||
correctOutput = "abc";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol decoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Lxfopv ef rnhr";
|
||||
keyword = "lemon";
|
||||
correctOutput = "attackatdawn";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding with mangled keyword
|
||||
input = "'Csastp' kv siqut gqu 'Csastpiuaqjb'";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "cryptoisshortforcryptography";
|
||||
output = cipher.decode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncode() throws Exception{
|
||||
Vigenere cipher = new Vigenere(true, true, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "XZB";
|
||||
String correctOutput = "xzb";
|
||||
String output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere Encoding failed the first test", correctOutput, output);
|
||||
assertEquals("Vigenere failed lowercase encoding.", correctOutput, output);
|
||||
//Test upercase encoding
|
||||
input = "ABC";
|
||||
keyword = "xyz";
|
||||
correctOutput = "XZB";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed uppercase encoding.", correctOutput, output);
|
||||
|
||||
//Test 2
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "a b c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "x z b";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "a@b^c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "x@z^b";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Attack at dawn";
|
||||
keyword = "Lemon";
|
||||
correctOutput = "LXFOPVEFRNHR";
|
||||
keyword = "lemon";
|
||||
correctOutput = "Lxfopv ef rnhr";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere Encoding failed the second test", correctOutput, output);
|
||||
|
||||
//Test 3
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding test 2
|
||||
input = "'Crypto' is short for 'Cryptography'";
|
||||
keyword = "abcd";
|
||||
correctOutput = "CSASTPKVSIQUTGQUCSASTPIUAQJB";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "'Csastp' kv siqut gqu 'Csastpiuaqjb'";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere Encoding failed the third test", correctOutput, output);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceEncode() throws Exception{
|
||||
Vigenere cipher = new Vigenere(true, false, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "xzb";
|
||||
String output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed lowercase encoding.", correctOutput, output);
|
||||
//Test upercase encoding
|
||||
input = "ABC";
|
||||
keyword = "xyz";
|
||||
correctOutput = "XZB";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed uppercase encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "a b c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "xzb";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "a@b^c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "x@z^b";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Attack at dawn";
|
||||
keyword = "lemon";
|
||||
correctOutput = "Lxfopvefrnhr";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding test 2
|
||||
input = "'Crypto' is short for 'Cryptography'";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "'Csastp'kvsiqutgqu'Csastpiuaqjb'";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCaptialEncode() throws Exception{
|
||||
Vigenere cipher = new Vigenere(false, true, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "xzb";
|
||||
String output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed lowercase encoding.", correctOutput, output);
|
||||
//Test upercase encoding
|
||||
input = "ABC";
|
||||
keyword = "xyz";
|
||||
correctOutput = "xzb";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed uppercase encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "a b c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "x z b";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "a@b^c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "x@z^b";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Attack at dawn";
|
||||
keyword = "lemon";
|
||||
correctOutput = "lxfopv ef rnhr";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding test 2
|
||||
input = "'Crypto' is short for 'Cryptography'";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "'csastp' kv siqut gqu 'csastpiuaqjb'";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolEncode() throws Exception{
|
||||
Vigenere cipher = new Vigenere(true, true, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "xzb";
|
||||
String output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed lowercase encoding.", correctOutput, output);
|
||||
//Test upercase encoding
|
||||
input = "ABC";
|
||||
keyword = "xyz";
|
||||
correctOutput = "XZB";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed uppercase encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "a b c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "x z b";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "a@b^c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "xzb";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Attack at dawn";
|
||||
keyword = "lemon";
|
||||
correctOutput = "Lxfopv ef rnhr";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding test 2
|
||||
input = "'Crypto' is short for 'Cryptography'";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "Csastp kv siqut gqu Csastpiuaqjb";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolEncode() throws Exception{
|
||||
Vigenere cipher = new Vigenere(false, false, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
String input = "abc";
|
||||
String keyword = "xyz";
|
||||
String correctOutput = "xzb";
|
||||
String output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed lowercase encoding.", correctOutput, output);
|
||||
//Test upercase encoding
|
||||
input = "ABC";
|
||||
keyword = "xyz";
|
||||
correctOutput = "xzb";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed uppercase encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test whitespace encoding
|
||||
input = "a b c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "xzb";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed whitespace encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test symbol decoding
|
||||
input = "a@b^c";
|
||||
keyword = "xyz";
|
||||
correctOutput = "xzb";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed symbol encoding.", correctOutput, output);
|
||||
|
||||
|
||||
//Test mixed case, whitespace, symbol decoding
|
||||
input = "Attack at dawn";
|
||||
keyword = "lemon";
|
||||
correctOutput = "lxfopvefrnhr";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding.", correctOutput, output);
|
||||
//Test mixed case, whitespace, symbol decoding test 2
|
||||
input = "'Crypto' is short for 'Cryptography'";
|
||||
keyword = " a@b C=d";
|
||||
correctOutput = "csastpkvsiqutgqucsastpiuaqjb";
|
||||
output = cipher.encode(keyword, input);
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testKeyword() throws Exception{
|
||||
Vigenere cipher = new Vigenere();
|
||||
|
||||
//Test keyword with whitespace
|
||||
String keyword = "x y z ";
|
||||
String correctOutput = "XYZ";
|
||||
cipher.setKeyword(keyword);
|
||||
String output = cipher.getKeyword();
|
||||
assertEquals("Vigenere failed keyword with whitespace", correctOutput, output);
|
||||
|
||||
|
||||
//Test keyword with symbol
|
||||
keyword = "x-y@z0";
|
||||
correctOutput = "XYZ";
|
||||
cipher.setKeyword(keyword);
|
||||
output = cipher.getKeyword();
|
||||
assertEquals("Vigenere failed keyword with symbol", correctOutput, output);
|
||||
|
||||
|
||||
//Test keyword with mixed case
|
||||
keyword = "xYz";
|
||||
correctOutput = "XYZ";
|
||||
cipher.setKeyword(keyword);
|
||||
output = cipher.getKeyword();
|
||||
assertEquals("Vigenere failed keyword with mixed case", correctOutput, output);
|
||||
|
||||
//Test keyword with whitespace, symbol and keyword
|
||||
keyword = "x Y%z ";
|
||||
correctOutput = "XYZ";
|
||||
cipher.setKeyword(keyword);
|
||||
output = cipher.getKeyword();
|
||||
assertEquals("Vigenere failed keyword with space, symbol, and mixed case", correctOutput, output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user