diff options
author | lloyd <[email protected]> | 2014-01-05 06:23:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-01-05 06:23:21 +0000 |
commit | c431fb65b883a0a5fa060ea7caace0aca3628ec6 (patch) | |
tree | 09898d2307801bffa7e1aeee9251d57ed4837870 /src/tests/test_modes.cpp | |
parent | 052345203b67eb5cacacd5659ec9837eeb59af35 (diff) |
Split up public key tests and data, use new test framework
Diffstat (limited to 'src/tests/test_modes.cpp')
-rw-r--r-- | src/tests/test_modes.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp index 1b546cea3..30c3c92db 100644 --- a/src/tests/test_modes.cpp +++ b/src/tests/test_modes.cpp @@ -35,15 +35,17 @@ secure_vector<byte> run_mode(const std::string& algo, return pipe.read_all(); } -bool mode_test(const std::string& algo, - const std::string& pt, - const std::string& ct, - const std::string& key_hex, - const std::string& nonce_hex) +size_t mode_test(const std::string& algo, + const std::string& pt, + const std::string& ct, + const std::string& key_hex, + const std::string& nonce_hex) { auto nonce = hex_decode_locked(nonce_hex); auto key = hex_decode_locked(key_hex); + size_t fails = 0; + const std::string ct2 = hex_encode(run_mode(algo, ENCRYPTION, hex_decode_locked(pt), @@ -51,7 +53,10 @@ bool mode_test(const std::string& algo, key)); if(ct != ct2) + { std::cout << algo << " got ct " << ct2 << " expected " << ct << "\n"; + ++fails; + } const std::string pt2 = hex_encode(run_mode(algo, DECRYPTION, @@ -60,16 +65,19 @@ bool mode_test(const std::string& algo, key)); if(pt != pt2) + { std::cout << algo << " got pt " << pt2 << " expected " << pt << "\n"; + ++fails; + } - return (ct == ct2) && (pt == pt2); + return fails; } } size_t test_modes() { - std::ifstream vec(CHECKS_DIR "/modes.vec"); + std::ifstream vec(TEST_DATA_DIR "/modes.vec"); return run_tests_bb(vec, "Mode", "Out", true, [](std::map<std::string, std::string> m) |