From a12115658a996c58a4b31412a97a2e2849f60393 Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Tue, 22 Feb 2022 18:42:11 +0000 Subject: [PATCH] Updated tests --- .../monoSubstitution/TestVigenere.java | 656 +++++++----------- 1 file changed, 269 insertions(+), 387 deletions(-) diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestVigenere.java b/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestVigenere.java index 29a0c0d..2cc1134 100644 --- a/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestVigenere.java +++ b/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestVigenere.java @@ -1,7 +1,7 @@ -//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestVigenere.java -//Matthew Ellison +//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestVigenere.java +//Mattrixwv // Created: 07-25-21 -//Modified: 01-09-22 +//Modified: 02-22-22 package com.mattrixwv.CipherStreamJava.monoSubstitution; @@ -19,235 +19,194 @@ public class TestVigenere{ Vigenere cipher = new Vigenere(true, true, true); //Test lowercase encoding - String input = "abc"; - String keyword = "xyz"; - String correctOutput = "xzb"; - String output = cipher.encode(keyword, input); + String inputString = "messagetoencode"; + String keyword = "keyword"; + String correctOutput = "wiqooxhdscjqfgo"; + String output = cipher.encode(keyword, inputString); assertEquals("Vigenere failed lowercase encoding.", correctOutput, output); - //Test upercase encoding - input = "ABC"; - keyword = "xyz"; - correctOutput = "XZB"; - output = cipher.encode(keyword, input); + //Test uppercase encoding + inputString = "MESSAGETOENCODE"; + keyword = "keyword"; + correctOutput = "WIQOOXHDSCJQFGO"; + output = cipher.encode(keyword, inputString); 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); + inputString = "message to encode"; + keyword = "keyword"; + correctOutput = "wiqooxh ds cjqfgo"; + output = cipher.encode(keyword, inputString); 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); + //Test symbol encoding + inputString = "message*to+encode"; + keyword = "keyword"; + correctOutput = "wiqooxh*ds+cjqfgo"; + output = cipher.encode(keyword, inputString); 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 mixed case, whitespace, symbol encoding + inputString = "Message to^encode"; + keyword = "keyword"; + correctOutput = "Wiqooxh ds^cjqfgo"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed symbol encoding.", correctOutput, output); } + @Test public void testNoCapitalEncode() throws InvalidKeywordException, InvalidInputException{ 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); - + String inputString = "messagetoencode"; + String keyword = "keyword"; + String correctOutput = "WIQOOXHDSCJQFGO"; + String output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no capital lowercase encoding.", correctOutput, output); + //Test uppercase encoding + inputString = "MESSAGETOENCODE"; + keyword = "keyword"; + correctOutput = "WIQOOXHDSCJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no capital 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); + inputString = "message to encode"; + keyword = "keyword"; + correctOutput = "WIQOOXH DS CJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no capital whitespace encoding.", correctOutput, output); + //Test symbol encoding + inputString = "message*to+encode"; + keyword = "keyword"; + correctOutput = "WIQOOXH*DS+CJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no capital symbol 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 mixed case, whitespace, symbol encoding + inputString = "Message to^encode"; + keyword = "keyword"; + correctOutput = "WIQOOXH DS^CJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no capital symbol encoding.", correctOutput, output); } + @Test public void testNoWhitespaceEncode() throws InvalidKeywordException, InvalidInputException{ 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); - + String inputString = "messagetoencode"; + String keyword = "keyword"; + String correctOutput = "wiqooxhdscjqfgo"; + String output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no whitespace lowercase encoding.", correctOutput, output); + //Test uppercase encoding + inputString = "MESSAGETOENCODE"; + keyword = "keyword"; + correctOutput = "WIQOOXHDSCJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no whitespace 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); + inputString = "message to encode"; + keyword = "keyword"; + correctOutput = "wiqooxhdscjqfgo"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no whitespace whitespace encoding.", correctOutput, output); + //Test symbol encoding + inputString = "message*to+encode"; + keyword = "keyword"; + correctOutput = "wiqooxh*ds+cjqfgo"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no whitespace symbol 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 mixed case, whitespace, symbol encoding + inputString = "Message to^encode"; + keyword = "keyword"; + correctOutput = "Wiqooxhds^cjqfgo"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no whitespace symbol encoding.", correctOutput, output); } + @Test public void testNoSymbolEncode() throws InvalidKeywordException, InvalidInputException{ 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); - + String inputString = "messagetoencode"; + String keyword = "keyword"; + String correctOutput = "wiqooxhdscjqfgo"; + String output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no symbol lowercase encoding.", correctOutput, output); + //Test uppercase encoding + inputString = "MESSAGETOENCODE"; + keyword = "keyword"; + correctOutput = "WIQOOXHDSCJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no symbol 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); + inputString = "message to encode"; + keyword = "keyword"; + correctOutput = "wiqooxh ds cjqfgo"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no symbol whitespace encoding.", correctOutput, output); + //Test symbol encoding + inputString = "message*to+encode"; + keyword = "keyword"; + correctOutput = "wiqooxhdscjqfgo"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no symbol symbol 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 mixed case, whitespace, symbol encoding + inputString = "Message to^encode"; + keyword = "keyword"; + correctOutput = "Wiqooxh dscjqfgo"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed no symbol symbol encoding.", correctOutput, output); } + @Test public void testNoCapitalWhitespaceSymbolEncode() throws InvalidKeywordException, InvalidInputException{ 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); - + String inputString = "messagetoencode"; + String keyword = "keyword"; + String correctOutput = "WIQOOXHDSCJQFGO"; + String output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed secure lowercase encoding.", correctOutput, output); + //Test uppercase encoding + inputString = "MESSAGETOENCODE"; + keyword = "keyword"; + correctOutput = "WIQOOXHDSCJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed secure 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); + inputString = "message to encode"; + keyword = "keyword"; + correctOutput = "WIQOOXHDSCJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed secure whitespace encoding.", correctOutput, output); + //Test symbol encoding + inputString = "message*to+encode"; + keyword = "keyword"; + correctOutput = "WIQOOXHDSCJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed secure symbol 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 mixed case, whitespace, symbol encoding + inputString = "Message to^encode"; + keyword = "keyword"; + correctOutput = "WIQOOXHDSCJQFGO"; + output = cipher.encode(keyword, inputString); + assertEquals("Vigenere failed secure symbol encoding.", correctOutput, output); } @@ -256,270 +215,193 @@ public class TestVigenere{ Vigenere cipher = new Vigenere(true, true, true); //Test lowercase decoding - String input = "xzb"; - String keyword = "xyz"; - String correctOutput = "abc"; - String output = cipher.decode(keyword, input); + String inputString = "wiqooxhdscjqfgo"; + String keyword = "keyword"; + String correctOutput = "messagetoencode"; + String output = cipher.decode(keyword, inputString); assertEquals("Vigenere failed lowercase decoding.", correctOutput, output); //Test uppercase decoding - input = "XZB"; - keyword = "XYZ"; - correctOutput = "ABC"; - output = cipher.decode(keyword, input); + inputString = "WIQOOXHDSCJQFGO"; + keyword = "keyword"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.decode(keyword, inputString); 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); + inputString = "wiqooxh ds cjqfgo"; + keyword = "keyword"; + correctOutput = "message to encode"; + output = cipher.decode(keyword, inputString); 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); + inputString = "wiqooxh*ds+cjqfgo"; + keyword = "keyword"; + correctOutput = "message*to+encode"; + output = cipher.decode(keyword, inputString); 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); + inputString = "Wiqooxh ds^cjqfgo"; + keyword = "keyword"; + correctOutput = "Message to^encode"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed symbol decoding.", correctOutput, output); } + @Test public void testNoCapitalDecode() throws InvalidKeywordException, InvalidInputException{ 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); + String inputString = "wiqooxhdscjqfgo"; + String keyword = "keyword"; + String correctOutput = "MESSAGETOENCODE"; + String output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no capital 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); - + inputString = "WIQOOXHDSCJQFGO"; + keyword = "keyword"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no capital 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); - + inputString = "wiqooxh ds cjqfgo"; + keyword = "keyword"; + correctOutput = "MESSAGE TO ENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no capital 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); - + inputString = "wiqooxh*ds+cjqfgo"; + keyword = "keyword"; + correctOutput = "MESSAGE*TO+ENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no capital 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); + inputString = "Wiqooxh ds^cjqfgo"; + keyword = "keyword"; + correctOutput = "MESSAGE TO^ENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no capital symbol decoding.", correctOutput, output); } + @Test public void testNoWhitespaceDecode() throws InvalidKeywordException, InvalidInputException{ Vigenere cipher = new Vigenere(true, false, 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); + String inputString = "wiqooxhdscjqfgo"; + String keyword = "keyword"; + String correctOutput = "messagetoencode"; + String output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no whitespace 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); - + inputString = "WIQOOXHDSCJQFGO"; + keyword = "keyword"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no whitespace 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); - + inputString = "wiqooxh ds cjqfgo"; + keyword = "keyword"; + correctOutput = "messagetoencode"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no whitespace 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); - + inputString = "wiqooxh*ds+cjqfgo"; + keyword = "keyword"; + correctOutput = "message*to+encode"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no whitespace 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); + inputString = "Wiqooxh ds^cjqfgo"; + keyword = "keyword"; + correctOutput = "Messageto^encode"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no whitespace symbol decoding.", correctOutput, output); } + @Test public void testNoSymbolDecode() throws InvalidKeywordException, InvalidInputException{ 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); + String inputString = "wiqooxhdscjqfgo"; + String keyword = "keyword"; + String correctOutput = "messagetoencode"; + String output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no symbol 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); - + inputString = "WIQOOXHDSCJQFGO"; + keyword = "keyword"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no symbol 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); - + inputString = "wiqooxh ds cjqfgo"; + keyword = "keyword"; + correctOutput = "message to encode"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no symbol 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); - + inputString = "wiqooxh*ds+cjqfgo"; + keyword = "keyword"; + correctOutput = "messagetoencode"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no symbol 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); + inputString = "Wiqooxh ds^cjqfgo"; + keyword = "keyword"; + correctOutput = "Message toencode"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed no symbol symbol decoding.", correctOutput, output); } + @Test - public void testNoCapitalWhitespaceSymbolDecode() throws InvalidKeywordException, InvalidInputException{ + public void testNoWhitespaceSymbolDecode() throws InvalidKeywordException, InvalidInputException{ 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); + String inputString = "wiqooxhdscjqfgo"; + String keyword = "keyword"; + String correctOutput = "MESSAGETOENCODE"; + String output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed secure 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); - + inputString = "WIQOOXHDSCJQFGO"; + keyword = "keyword"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed secure 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); - + inputString = "wiqooxh ds cjqfgo"; + keyword = "keyword"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed secure 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); - + inputString = "wiqooxh*ds+cjqfgo"; + keyword = "keyword"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed secure 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 testKeyword() throws InvalidKeywordException{ - 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); + inputString = "Wiqooxh ds^cjqfgo"; + keyword = "keyword"; + correctOutput = "MESSAGETOENCODE"; + output = cipher.decode(keyword, inputString); + assertEquals("Vigenere failed secure symbol decoding.", correctOutput, output); } }