mirror of
https://bitbucket.org/Mattrixwv/cipherstream.git
synced 2025-12-06 18:33:58 -05:00
Added test for Autokey Cipher
This commit is contained in:
26
testMain.hpp
26
testMain.hpp
@@ -437,6 +437,32 @@ bool autokeyTest(std::string& errorString){
|
|||||||
errorString += testingError(DECODE, outputString, inputString, cipherString);
|
errorString += testingError(DECODE, outputString, inputString, cipherString);
|
||||||
passed = false;
|
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
|
#endif //AUTOKEY_TEST
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user