From 23d3931ef1c6c0ea6c9087f64247fe320787e291 Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Wed, 2 May 2018 11:21:01 -0400 Subject: [PATCH] Added test for Autokey Cipher --- testMain.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/testMain.hpp b/testMain.hpp index 0c51430..04b3307 100644 --- a/testMain.hpp +++ b/testMain.hpp @@ -437,6 +437,32 @@ bool autokeyTest(std::string& errorString){ errorString += testingError(DECODE, outputString, inputString, cipherString); passed = false; } + + + //Another test from wikipedia + keyword = "KILT"; + inputString = "MEETATTHEFOUNTAIN"; + outputString = "WMPMMXXAEYHBRYOCA"; + //Setup the cipher + cipherString = cipher.encode(keyword, inputString); + //If the cipher didn't spit out the correct string throw an error + if(cipherString != outputString){ + errorString += testingError(ENCODE, inputString, outputString, cipherString); + passed = false; + } + //This removes the spaces and turns everything capital so the reverse will work correctly + inputString = cipher.getInputString(); + + //Do the same thing in reverse + cipher.reset(); + cipherString = cipher.decode(keyword, outputString); + //If the cipher didn't spit out the correct string throw an error + if(cipherString != inputString){ + errorString += testingError(DECODE, outputString, inputString, cipherString); + passed = false; + } + + return passed; } #endif //AUTOKEY_TEST