diff options
author | Simon Warta <[email protected]> | 2015-06-19 13:11:49 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-06-19 13:11:49 +0200 |
commit | 6750b13cc04e4a6a2f1aad364f74d0042d1da766 (patch) | |
tree | e4f4ee0dfe1787867218c1d8c334a2382318e057 /src/tests | |
parent | b9c03ac33472b00a3eeb8bc00b7f37ef610a4eac (diff) |
Replace \n by std::endl in tests to ensure proper flushing
- Remove additional newlines in CHECK_MESSAGE call
- Remove redundant output of algo in aead_test()
Closes #115
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/nist_x509.cpp | 2 | ||||
-rw-r--r-- | src/tests/test_aead.cpp | 11 | ||||
-rw-r--r-- | src/tests/test_block.cpp | 6 | ||||
-rw-r--r-- | src/tests/test_c25519.cpp | 2 | ||||
-rw-r--r-- | src/tests/test_compression.cpp | 6 | ||||
-rw-r--r-- | src/tests/test_cryptobox.cpp | 2 | ||||
-rw-r--r-- | src/tests/test_cvc.cpp | 8 | ||||
-rw-r--r-- | src/tests/test_ecdsa.cpp | 4 | ||||
-rw-r--r-- | src/tests/test_hash.cpp | 10 | ||||
-rw-r--r-- | src/tests/test_keywrap.cpp | 6 | ||||
-rw-r--r-- | src/tests/test_mac.cpp | 8 | ||||
-rw-r--r-- | src/tests/test_mceliece.cpp | 8 | ||||
-rw-r--r-- | src/tests/test_modes.cpp | 4 | ||||
-rw-r--r-- | src/tests/test_ocb.cpp | 6 | ||||
-rw-r--r-- | src/tests/test_passhash.cpp | 10 | ||||
-rw-r--r-- | src/tests/test_pubkey.cpp | 26 | ||||
-rw-r--r-- | src/tests/test_rfc6979.cpp | 8 | ||||
-rw-r--r-- | src/tests/test_rng.cpp | 4 | ||||
-rw-r--r-- | src/tests/test_srp6.cpp | 2 | ||||
-rw-r--r-- | src/tests/test_stream.cpp | 6 | ||||
-rw-r--r-- | src/tests/test_tss.cpp | 6 | ||||
-rw-r--r-- | src/tests/tests.cpp | 20 | ||||
-rw-r--r-- | src/tests/unit_ecc.cpp | 16 | ||||
-rw-r--r-- | src/tests/unit_ecdh.cpp | 10 | ||||
-rw-r--r-- | src/tests/unit_ecdsa.cpp | 30 | ||||
-rw-r--r-- | src/tests/unit_tls.cpp | 20 | ||||
-rw-r--r-- | src/tests/unit_x509.cpp | 2 |
27 files changed, 121 insertions, 122 deletions
diff --git a/src/tests/nist_x509.cpp b/src/tests/nist_x509.cpp index ffd3130c7..734f2b355 100644 --- a/src/tests/nist_x509.cpp +++ b/src/tests/nist_x509.cpp @@ -39,7 +39,7 @@ size_t test_nist_x509() if(list_all_readable_files_in_or_under(root_test_dir).empty()) { - std::cout << "No FS access, skipping NIST X.509 validation tests\n"; + std::cout << "No FS access, skipping NIST X.509 validation tests" << std::endl; test_report("NIST X.509 path validation", 0, 0); return 0; } diff --git a/src/tests/test_aead.cpp b/src/tests/test_aead.cpp index f5445f8e2..e9f002e19 100644 --- a/src/tests/test_aead.cpp +++ b/src/tests/test_aead.cpp @@ -53,8 +53,7 @@ size_t aead_test(const std::string& algo, if(vec != expected_ct) { - std::cout << algo << " got ct " << hex_encode(vec) << " expected " << expected << "\n"; - std::cout << algo << "\n"; + std::cout << algo << " got ct " << hex_encode(vec) << " expected " << expected << std::endl; ++fail; } @@ -65,7 +64,7 @@ size_t aead_test(const std::string& algo, if(vec != pt) { - std::cout << algo << " got pt " << hex_encode(vec) << " expected " << input << "\n"; + std::cout << algo << " got pt " << hex_encode(vec) << " expected " << input << std::endl; ++fail; } @@ -77,7 +76,7 @@ size_t aead_test(const std::string& algo, try { dec->finish(vec); - std::cout << algo << " accepted message with modified message\n"; + std::cout << algo << " accepted message with modified message" << std::endl; ++fail; } catch(...) {} @@ -93,7 +92,7 @@ size_t aead_test(const std::string& algo, try { dec->finish(vec); - std::cout << algo << " accepted message with modified nonce\n"; + std::cout << algo << " accepted message with modified nonce" << std::endl; ++fail; } catch(...) {} @@ -116,7 +115,7 @@ size_t aead_test(const std::string& algo, try { dec->finish(vec); - std::cout << algo << " accepted message with modified AD\n"; + std::cout << algo << " accepted message with modified AD" << std::endl; ++fail; } catch(...) {} diff --git a/src/tests/test_block.cpp b/src/tests/test_block.cpp index 066f2201a..50801cf21 100644 --- a/src/tests/test_block.cpp +++ b/src/tests/test_block.cpp @@ -37,7 +37,7 @@ size_t block_test(const std::string& algo, if(!cipher) { - std::cout << "Unable to get " << algo << " from " << provider << "\n"; + std::cout << "Unable to get " << algo << " from " << provider << std::endl; ++fails; continue; } @@ -49,7 +49,7 @@ size_t block_test(const std::string& algo, if(buf != ct) { - std::cout << algo << " " << provider << " enc " << hex_encode(buf) << " != " << out_hex << "\n"; + std::cout << algo << " " << provider << " enc " << hex_encode(buf) << " != " << out_hex << std::endl; ++fails; buf = ct; } @@ -58,7 +58,7 @@ size_t block_test(const std::string& algo, if(buf != pt) { - std::cout << algo << " " << provider << " dec " << hex_encode(buf) << " != " << out_hex << "\n"; + std::cout << algo << " " << provider << " dec " << hex_encode(buf) << " != " << out_hex << std::endl; ++fails; } } diff --git a/src/tests/test_c25519.cpp b/src/tests/test_c25519.cpp index 3dbc92492..f8dfd3b85 100644 --- a/src/tests/test_c25519.cpp +++ b/src/tests/test_c25519.cpp @@ -33,7 +33,7 @@ size_t curve25519_scalar_kat(const std::string& secret_h, if(got != out) { - std::cout << "Got " << hex_encode(got) << " exp " << hex_encode(out) << "\n"; + std::cout << "Got " << hex_encode(got) << " exp " << hex_encode(out) << std::endl; return 1; } diff --git a/src/tests/test_compression.cpp b/src/tests/test_compression.cpp index 2dc8f65e2..9b83737a0 100644 --- a/src/tests/test_compression.cpp +++ b/src/tests/test_compression.cpp @@ -25,7 +25,7 @@ size_t run_compression(Compressor_Transform& c, Transform& d, if(msg != decompressed) { std::cout << hex_encode(msg) << " compressed to " << hex_encode(compressed) - << " but did not roundtrip - " << hex_encode(decompressed) << "\n"; + << " but did not roundtrip - " << hex_encode(decompressed) << std::endl; } return c_size; @@ -103,7 +103,7 @@ size_t test_compression() const size_t c1_t = run_compression(*c1, *d, text); const size_t c9_t = run_compression(*c9, *d, text); -#define BOTAN_TEST_GTE(x, y, msg) if(x < y) { ++fails; std::cout << "FAIL: " << x << " " << y << " " << msg << '\n'; } +#define BOTAN_TEST_GTE(x, y, msg) if(x < y) { ++fails; std::cout << "FAIL: " << x << " " << y << " " << msg << std::endl; } BOTAN_TEST_GTE(c1_z, c9_z, "Level 9 compresses at least as well as level 1"); BOTAN_TEST_GTE(c1_t, c9_t, "Level 9 compresses at least as well as level 1"); @@ -114,7 +114,7 @@ size_t test_compression() } catch(std::exception& e) { - std::cout << "Failure testing " << algo << " - " << e.what() << "\n"; + std::cout << "Failure testing " << algo << " - " << e.what() << std::endl; ++fails; } } diff --git a/src/tests/test_cryptobox.cpp b/src/tests/test_cryptobox.cpp index 433d64d50..74686a298 100644 --- a/src/tests/test_cryptobox.cpp +++ b/src/tests/test_cryptobox.cpp @@ -38,7 +38,7 @@ size_t test_cryptobox() } catch(std::exception& e) { - std::cout << "Error during Cryptobox test " << e.what() << "\n"; + std::cout << "Error during Cryptobox test " << e.what() << std::endl; ++fails; } diff --git a/src/tests/test_cvc.cpp b/src/tests/test_cvc.cpp index 669aaa07a..eb10ebd40 100644 --- a/src/tests/test_cvc.cpp +++ b/src/tests/test_cvc.cpp @@ -35,8 +35,8 @@ using namespace Botan; -#define CHECK_MESSAGE(expr, print) try { if(!(expr)) std::cout << print << "\n"; } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << "\n"; } -#define CHECK(expr) try { if(!(expr)) std::cout << #expr << "\n"; } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << "\n"; } +#define CHECK_MESSAGE(expr, print) try { if(!(expr)) std::cout << print << std::endl; } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << std::endl; } +#define CHECK(expr) try { if(!(expr)) std::cout << #expr << std::endl; } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << std::endl; } namespace { @@ -134,7 +134,7 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng) CHECK(sv1.size() > 10); CHECK_MESSAGE(sv1 == sv2, "reencoded file of cert without domain parameters is different from original"); - //cout << "reading cert again\n"; + //cout << "reading cert again" << std::endl; CHECK(cert_in.get_car().value() == "my_opt_car"); CHECK(cert_in.get_chr().value() == "my_opt_car"); CHECK(cert_in.get_ced().as_string() == "20100727"); @@ -161,7 +161,7 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng) ill_date_exc2 = true; } CHECK(ill_date_exc2); - //cout << "readable = '" << cert_in.get_ced().readable_string() << "'\n"; + //cout << "readable = '" << cert_in.get_ced().readable_string() << "'" << std::endl; std::unique_ptr<Public_Key> p_pk(cert_in.subject_public_key()); ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get()); diff --git a/src/tests/test_ecdsa.cpp b/src/tests/test_ecdsa.cpp index e8962b748..53f32ab49 100644 --- a/src/tests/test_ecdsa.cpp +++ b/src/tests/test_ecdsa.cpp @@ -58,13 +58,13 @@ size_t ecc_point_mul(const std::string& group_id, if(p.get_affine_x() != X) { - std::cout << p.get_affine_x() << " != " << X << "\n"; + std::cout << p.get_affine_x() << " != " << X << std::endl; ++fails; } if(p.get_affine_y() != Y) { - std::cout << p.get_affine_y() << " != " << Y << "\n"; + std::cout << p.get_affine_y() << " != " << Y << std::endl; ++fails; } diff --git a/src/tests/test_hash.cpp b/src/tests/test_hash.cpp index e301f2d4c..abc3a2f95 100644 --- a/src/tests/test_hash.cpp +++ b/src/tests/test_hash.cpp @@ -26,7 +26,7 @@ size_t hash_test(const std::string& algo, if(providers.empty()) { - std::cout << "Unknown hash '" << algo << "'\n"; + std::cout << "Unknown hash '" << algo << "'" << std::endl; ++fails; } @@ -36,7 +36,7 @@ size_t hash_test(const std::string& algo, if(!hash) { - std::cout << "Unable to get " << algo << " from " << provider << "\n"; + std::cout << "Unable to get " << algo << " from " << provider << std::endl; ++fails; continue; } @@ -49,7 +49,7 @@ size_t hash_test(const std::string& algo, if(h != hex_decode_locked(out_hex)) { - std::cout << algo << " " << provider << " got " << hex_encode(h) << " != " << out_hex << "\n"; + std::cout << algo << " " << provider << " got " << hex_encode(h) << " != " << out_hex << std::endl; ++fails; } @@ -64,7 +64,7 @@ size_t hash_test(const std::string& algo, if(h != hex_decode_locked(out_hex)) { std::cout << algo << " " << provider << " got " << hex_encode(h) << " != " << out_hex - << " (with discarded input)\n"; + << " (with discarded input)" << std::endl; ++fails; } @@ -77,7 +77,7 @@ size_t hash_test(const std::string& algo, if(h != hex_decode_locked(out_hex)) { std::cout << algo << " " << provider << " got " << hex_encode(h) << " != " << out_hex - << " (with offset input)\n"; + << " (with offset input)" << std::endl; ++fails; } } diff --git a/src/tests/test_keywrap.cpp b/src/tests/test_keywrap.cpp index ffe9b52bb..16a165668 100644 --- a/src/tests/test_keywrap.cpp +++ b/src/tests/test_keywrap.cpp @@ -36,7 +36,7 @@ size_t keywrap_test(const char* key_str, if(enc != expected.bits_of()) { std::cout << "NIST key wrap encryption failure: " - << hex_encode(enc) << " != " << hex_encode(expected.bits_of()) << "\n"; + << hex_encode(enc) << " != " << hex_encode(expected.bits_of()) << std::endl; fail++; } @@ -45,13 +45,13 @@ size_t keywrap_test(const char* key_str, if(dec != key.bits_of()) { std::cout << "NIST key wrap decryption failure: " - << hex_encode(dec) << " != " << hex_encode(key.bits_of()) << "\n"; + << hex_encode(dec) << " != " << hex_encode(key.bits_of()) << std::endl; fail++; } } catch(std::exception& e) { - std::cout << e.what() << "\n"; + std::cout << e.what() << std::endl; fail++; } #endif diff --git a/src/tests/test_mac.cpp b/src/tests/test_mac.cpp index 302f39625..e191a6ed7 100644 --- a/src/tests/test_mac.cpp +++ b/src/tests/test_mac.cpp @@ -26,7 +26,7 @@ size_t mac_test(const std::string& algo, if(providers.empty()) { - std::cout << "Unknown algo " << algo << "\n"; + std::cout << "Unknown algo " << algo << std::endl; ++fails; } @@ -36,7 +36,7 @@ size_t mac_test(const std::string& algo, if(!mac) { - std::cout << "Unable to get " << algo << " from " << provider << "\n"; + std::cout << "Unable to get " << algo << " from " << provider << std::endl; ++fails; continue; } @@ -52,7 +52,7 @@ size_t mac_test(const std::string& algo, if(out != exp) { - std::cout << algo << " " << provider << " got " << hex_encode(out) << " != " << hex_encode(exp) << "\n"; + std::cout << algo << " " << provider << " got " << hex_encode(out) << " != " << hex_encode(exp) << std::endl; ++fails; } @@ -67,7 +67,7 @@ size_t mac_test(const std::string& algo, if(out2 != exp) { - std::cout << algo << " " << provider << " got " << hex_encode(out2) << " != " << hex_encode(exp) << "\n"; + std::cout << algo << " " << provider << " got " << hex_encode(out2) << " != " << hex_encode(exp) << std::endl; ++fails; } } diff --git a/src/tests/test_mceliece.cpp b/src/tests/test_mceliece.cpp index ca497f542..f55492e95 100644 --- a/src/tests/test_mceliece.cpp +++ b/src/tests/test_mceliece.cpp @@ -25,8 +25,8 @@ using namespace Botan; -#define CHECK_MESSAGE(expr, print) do {if(!(expr)) {std::cout << print << "\n"; return 1;} }while(0) -#define CHECK(expr) do {if(!(expr)) { std::cout << #expr << "\n"; return 1; } }while(0) +#define CHECK_MESSAGE(expr, print) do {if(!(expr)) {std::cout << print << std::endl; return 1;} }while(0) +#define CHECK(expr) do {if(!(expr)) { std::cout << #expr << std::endl; return 1; } }while(0) namespace { @@ -178,7 +178,7 @@ size_t test_mceies(const McEliece_PrivateKey& sk, if(pt != dec) { - std::cout << "MCEIES " << hex_encode(pt) << " != " << hex_encode(dec) << "\n"; + std::cout << "MCEIES " << hex_encode(pt) << " != " << hex_encode(dec) << std::endl; ++fails; } @@ -196,7 +196,7 @@ size_t test_mceies(const McEliece_PrivateKey& sk, try { mceies_decrypt(sk, bad_ct, ad, ad_len); - std::cout << "Successfully decrypted manipulated ciphertext!\n"; + std::cout << "Successfully decrypted manipulated ciphertext!" << std::endl; ++fails; } catch(std::exception& e) { /* Yay */ } diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp index 5ff6c03dc..35853ba82 100644 --- a/src/tests/test_modes.cpp +++ b/src/tests/test_modes.cpp @@ -60,7 +60,7 @@ size_t mode_test(const std::string& algo, if(ct != ct2) { - std::cout << algo << " got ct " << ct2 << " expected " << ct << "\n"; + std::cout << algo << " got ct " << ct2 << " expected " << ct << std::endl; ++fails; } @@ -72,7 +72,7 @@ size_t mode_test(const std::string& algo, if(pt != pt2) { - std::cout << algo << " got pt " << pt2 << " expected " << pt << "\n"; + std::cout << algo << " got pt " << pt2 << " expected " << pt << std::endl; ++fails; } diff --git a/src/tests/test_ocb.cpp b/src/tests/test_ocb.cpp index 95f91ab50..c27753214 100644 --- a/src/tests/test_ocb.cpp +++ b/src/tests/test_ocb.cpp @@ -43,11 +43,11 @@ std::vector<byte> ocb_encrypt(OCB_Encryption& enc, dec.finish(ct, 0); if(ct != pt) - std::cout << "OCB failed to decrypt correctly\n"; + std::cout << "OCB failed to decrypt correctly" << std::endl; } catch(std::exception& e) { - std::cout << "OCB round trip error - " << e.what() << "\n"; + std::cout << "OCB round trip error - " << e.what() << std::endl; } return unlock(buf); @@ -94,7 +94,7 @@ size_t test_ocb_long(size_t keylen, size_t taglen, if(cipher_hex != expected) { std::cout << "OCB " << algo << " long test mistmatch " - << cipher_hex << " != " << expected << "\n"; + << cipher_hex << " != " << expected << std::endl; return 1; } diff --git a/src/tests/test_passhash.cpp b/src/tests/test_passhash.cpp index 17aef2204..4bc69125b 100644 --- a/src/tests/test_passhash.cpp +++ b/src/tests/test_passhash.cpp @@ -27,7 +27,7 @@ size_t test_bcrypt() // Generated by jBCrypt 0.3 if(!check_bcrypt("abc", "$2a$05$DfPyLs.G6.To9fXEFgUL1O6HpYw3jIXgPcl/L3Qt3jESuWmhxtmpS")) { - std::cout << "Bcrypt test 1 failed\n"; + std::cout << "Bcrypt test 1 failed" << std::endl; fails++; } @@ -35,7 +35,7 @@ size_t test_bcrypt() if(!check_bcrypt("\xA3", "$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq")) { - std::cout << "Bcrypt test 2 failed\n"; + std::cout << "Bcrypt test 2 failed" << std::endl; fails++; } @@ -48,7 +48,7 @@ size_t test_bcrypt() if(!check_bcrypt(input, gen_hash)) { - std::cout << "Gen and check for bcrypt failed: " << gen_hash << " not valid\n"; + std::cout << "Gen and check for bcrypt failed: " << gen_hash << " not valid" << std::endl; ++fails; } } @@ -74,7 +74,7 @@ size_t test_passhash9() ++ran; if(!check_passhash9(input, fixed_hash)) { - std::cout << "Passhash9 fixed input test failed\n"; + std::cout << "Passhash9 fixed input test failed" << std::endl; fails++; } @@ -87,7 +87,7 @@ size_t test_passhash9() ++ran; if(!check_passhash9(input, gen_hash)) { - std::cout << "Passhash9 gen and check " << static_cast<int>(alg_id) << " failed\n"; + std::cout << "Passhash9 gen and check " << static_cast<int>(alg_id) << " failed" << std::endl; ++fails; } } diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp index 05119baa5..bde32c687 100644 --- a/src/tests/test_pubkey.cpp +++ b/src/tests/test_pubkey.cpp @@ -97,20 +97,20 @@ size_t validate_save_and_load(const Private_Key* priv_key, if(!restored_pub.get()) { - std::cout << "Could not recover " << name << " public key\n"; + std::cout << "Could not recover " << name << " public key" << std::endl; ++fails; } else if(restored_pub->check_key(rng, true) == false) { - std::cout << "Restored pubkey failed self tests " << name << "\n"; + std::cout << "Restored pubkey failed self tests " << name << std::endl; ++fails; } } catch(std::exception& e) { std::cout << "Exception during load of " << name - << " key: " << e.what() << "\n"; - std::cout << "PEM for pubkey was:\n" << pub_pem << "\n"; + << " key: " << e.what() << std::endl; + std::cout << "PEM for pubkey was:\n" << pub_pem << std::endl; ++fails; } @@ -124,20 +124,20 @@ size_t validate_save_and_load(const Private_Key* priv_key, if(!restored_priv.get()) { - std::cout << "Could not recover " << name << " privlic key\n"; + std::cout << "Could not recover " << name << " privlic key" << std::endl; ++fails; } else if(restored_priv->check_key(rng, true) == false) { - std::cout << "Restored privkey failed self tests " << name << "\n"; + std::cout << "Restored privkey failed self tests " << name << std::endl; ++fails; } } catch(std::exception& e) { std::cout << "Exception during load of " << name - << " key: " << e.what() << "\n"; - std::cout << "PEM for privkey was:\n" << priv_pem << "\n"; + << " key: " << e.what() << std::endl; + std::cout << "PEM for privkey was:\n" << priv_pem << std::endl; ++fails; } @@ -159,7 +159,7 @@ byte nonzero_byte(RandomNumberGenerator& rng) const bool test_result = expr; \ if(!test_result) \ { \ - std::cout << "Test " << #expr << " failed: " << msg << "\n"; \ + std::cout << "Test " << #expr << " failed: " << msg << std::endl; \ ++fails; \ } \ } while(0) @@ -206,15 +206,15 @@ size_t validate_encryption(PK_Encryptor& e, PK_Decryptor& d, try { auto bad_ptext = unlock(d.decrypt(bad_ctext)); - std::cout << algo << " failed - decrypted bad data\n"; - std::cout << hex_encode(bad_ctext) << " -> " << hex_encode(bad_ptext) << "\n"; - std::cout << hex_encode(ctext) << " -> " << hex_encode(decrypted) << "\n"; + std::cout << algo << " failed - decrypted bad data" << std::endl; + std::cout << hex_encode(bad_ctext) << " -> " << hex_encode(bad_ptext) << std::endl; + std::cout << hex_encode(ctext) << " -> " << hex_encode(decrypted) << std::endl; // Ignore PKCS #1 failures as they do occur occasionally (million message attack) const bool is_pkcs1 = algo.find("/EME-PKCS1-v1_5") != std::string::npos; if(is_pkcs1) - std::cout << "Ignoring PKCS #1 failure\n"; + std::cout << "Ignoring PKCS #1 failure" << std::endl; else ++fails; } diff --git a/src/tests/test_rfc6979.cpp b/src/tests/test_rfc6979.cpp index c0bdd5822..772a492c3 100644 --- a/src/tests/test_rfc6979.cpp +++ b/src/tests/test_rfc6979.cpp @@ -38,7 +38,7 @@ size_t rfc6979_testcase(const std::string& q_str, if(gen_k != exp_k) { std::cout << "RFC 6979 test #" << testcase << " failed; generated k=" - << std::hex << gen_k << "\n"; + << std::hex << gen_k << std::endl; ++fails; } @@ -48,7 +48,7 @@ size_t rfc6979_testcase(const std::string& q_str, if(gen_0 != exp_k) { std::cout << "RFC 6979 test #" << testcase << " failed; generated k=" - << std::hex << gen_0 << " (gen_0)\n"; + << std::hex << gen_0 << " (gen_0)" << std::endl; ++fails; } @@ -56,7 +56,7 @@ size_t rfc6979_testcase(const std::string& q_str, if(gen_1 == exp_k) { std::cout << "RFC 6979 test #" << testcase << " failed; generated k=" - << std::hex << gen_1 << " (gen_1)\n"; + << std::hex << gen_1 << " (gen_1)" << std::endl; ++fails; } @@ -64,7 +64,7 @@ size_t rfc6979_testcase(const std::string& q_str, if(gen_2 != exp_k) { std::cout << "RFC 6979 test #" << testcase << " failed; generated k=" - << std::hex << gen_2 << " (gen_2)\n"; + << std::hex << gen_2 << " (gen_2)" << std::endl; ++fails; } diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp index 1f8edf332..f0efb36c3 100644 --- a/src/tests/test_rng.cpp +++ b/src/tests/test_rng.cpp @@ -73,7 +73,7 @@ size_t x931_test(const std::string& algo, if(got != out) { - std::cout << "X9.31 " << got << " != " << out << "\n"; + std::cout << "X9.31 " << got << " != " << out << std::endl; return 1; } @@ -105,7 +105,7 @@ size_t hmac_drbg_test(std::map<std::string, std::string> m) if(got != out) { - std::cout << algo << " " << got << " != " << out << "\n"; + std::cout << algo << " " << got << " != " << out << std::endl; return 1; } diff --git a/src/tests/test_srp6.cpp b/src/tests/test_srp6.cpp index 010576110..fcc049c11 100644 --- a/src/tests/test_srp6.cpp +++ b/src/tests/test_srp6.cpp @@ -28,7 +28,7 @@ size_t test_srp6() if(client.second != server_K) { - std::cout << "SRP6 computed different keys\n"; + std::cout << "SRP6 computed different keys" << std::endl; ++fails; } diff --git a/src/tests/test_stream.cpp b/src/tests/test_stream.cpp index af782d219..6f14c7183 100644 --- a/src/tests/test_stream.cpp +++ b/src/tests/test_stream.cpp @@ -32,7 +32,7 @@ size_t stream_test(const std::string& algo, if(providers.empty()) { - std::cout << "Unknown stream cipher " << algo << "\n"; + std::cout << "Unknown stream cipher " << algo << std::endl; ++fails; } @@ -42,7 +42,7 @@ size_t stream_test(const std::string& algo, if(!cipher) { - std::cout << "Unable to get " << algo << " from " << provider << "\n"; + std::cout << "Unable to get " << algo << " from " << provider << std::endl; ++fails; continue; } @@ -58,7 +58,7 @@ size_t stream_test(const std::string& algo, if(buf != ct) { - std::cout << algo << " " << provider << " enc " << hex_encode(buf) << " != " << out_hex << "\n"; + std::cout << algo << " " << provider << " enc " << hex_encode(buf) << " != " << out_hex << std::endl; ++fails; } } diff --git a/src/tests/test_tss.cpp b/src/tests/test_tss.cpp index 3bb54e4f6..36f075c54 100644 --- a/src/tests/test_tss.cpp +++ b/src/tests/test_tss.cpp @@ -34,7 +34,7 @@ size_t test_tss() if(S != back) { - std::cout << "TSS-0: " << hex_encode(S) << " != " << hex_encode(back) << "\n"; + std::cout << "TSS-0: " << hex_encode(S) << " != " << hex_encode(back) << std::endl; ++fails; } @@ -44,7 +44,7 @@ size_t test_tss() if(S != back) { - std::cout << "TSS-1: " << hex_encode(S) << " != " << hex_encode(back) << "\n"; + std::cout << "TSS-1: " << hex_encode(S) << " != " << hex_encode(back) << std::endl; ++fails; } @@ -53,7 +53,7 @@ size_t test_tss() #else size_t test_tss() { - std::cout << "Skipping TSS tests\n"; + std::cout << "Skipping TSS tests" << std::endl; return 1; } #endif diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 3213429b2..14588cf0d 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -45,12 +45,12 @@ size_t run_tests(const std::vector<test_fn>& tests) } catch(std::exception& e) { - std::cout << "Exception escaped test: " << e.what() << "\n"; + std::cout << "Exception escaped test: " << e.what() << std::endl; ++fails; } catch(...) { - std::cout << "Exception escaped test\n"; + std::cout << "Exception escaped test" << std::endl; ++fails; } } @@ -81,7 +81,7 @@ size_t run_tests_bb(std::istream& src, { if(!src.good()) { - std::cout << "Could not open input file for " << name_key << "\n"; + std::cout << "Could not open input file for " << name_key << std::endl; return 1; } @@ -126,7 +126,7 @@ size_t run_tests_bb(std::istream& src, if(key == output_key) { - //std::cout << vars[name_key] << " " << algo_count << "\n"; + //std::cout << vars[name_key] << " " << algo_count << std::endl; ++algo_count; try { @@ -134,13 +134,13 @@ size_t run_tests_bb(std::istream& src, if(fails) { - std::cout << vars[name_key] << " test " << algo_count << ": " << fails << " failure\n"; + std::cout << vars[name_key] << " test " << algo_count << ": " << fails << " failure" << std::endl; algo_fail += fails; } } catch(std::exception& e) { - std::cout << vars[name_key] << " test " << algo_count << " failed: " << e.what() << "\n"; + std::cout << vars[name_key] << " test " << algo_count << " failed: " << e.what() << std::endl; ++algo_fail; } @@ -173,7 +173,7 @@ size_t run_tests(const std::string& filename, if(!vec) { - std::cout << "Failure opening " << filename << "\n"; + std::cout << "Failure opening " << filename << std::endl; return 1; } @@ -204,8 +204,8 @@ namespace { int help(char* argv0) { - std::cout << "Usage: " << argv0 << " [suite]\n"; - std::cout << "Suites: all (default), block, hash, bigint, rsa, ecdsa, ...\n"; + std::cout << "Usage: " << argv0 << " [suite]" << std::endl; + std::cout << "Suites: all (default), block, hash, bigint, rsa, ecdsa, ..." << std::endl; return 1; } @@ -277,7 +277,7 @@ int main(int argc, char* argv[]) if(tests.empty()) { - std::cout << "No tests selected by target '" << target << "'\n"; + std::cout << "No tests selected by target '" << target << "'" << std::endl; return 1; } diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp index d198c25d8..2bae63936 100644 --- a/src/tests/unit_ecc.cpp +++ b/src/tests/unit_ecc.cpp @@ -22,8 +22,8 @@ using namespace Botan; -#define CHECK_MESSAGE(expr, print) try { if(!(expr)) { ++fails; std::cout << "FAILURE: " << print << "\n"; }} catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << "\n"; } -#define CHECK(expr) try { if(!(expr)) { ++fails; std::cout << "FAILURE: " << #expr << "\n"; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << "\n"; } +#define CHECK_MESSAGE(expr, print) try { if(!(expr)) { ++fails; std::cout << "FAILURE: " << print << std::endl; }} catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << std::endl; } +#define CHECK(expr) try { if(!(expr)) { ++fails; std::cout << "FAILURE: " << #expr << std::endl; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << std::endl; } namespace { @@ -151,8 +151,8 @@ size_t test_coordinates() if(!point_exp.on_the_curve()) throw Internal_Error("Point not on the curve"); - CHECK_MESSAGE( p1.get_affine_x() == exp_affine_x, " p1_x = " << p1.get_affine_x() << "\n" << "exp_x = " << exp_affine_x << "\n"); - CHECK_MESSAGE( p1.get_affine_y() == exp_affine_y, " p1_y = " << p1.get_affine_y() << "\n" << "exp_y = " << exp_affine_y << "\n"); + CHECK_MESSAGE(p1.get_affine_x() == exp_affine_x, "p1_x = " << p1.get_affine_x() << "\n" << "exp_x = " << exp_affine_x); + CHECK_MESSAGE(p1.get_affine_y() == exp_affine_y, "p1_y = " << p1.get_affine_y() << "\n" << "exp_y = " << exp_affine_y); return fails; } @@ -460,7 +460,7 @@ size_t test_basic_operations() BigInt("704859595002530890444080436569091156047721708633"), BigInt("1147993098458695153857594941635310323215433166682")); if(simplePlus != exp_simplePlus) - std::cout << simplePlus << " != " << exp_simplePlus << "\n"; + std::cout << simplePlus << " != " << exp_simplePlus << std::endl; PointGFp simpleMinus= p1 - p0; PointGFp exp_simpleMinus(secp160r1, @@ -600,7 +600,7 @@ size_t test_enc_dec_uncompressed_521() std::string result = hex_encode(&sv_result[0], sv_result.size()); std::string exp_result = hex_encode(&sv_G_secp_uncomp[0], sv_G_secp_uncomp.size()); - CHECK_MESSAGE( sv_result == sv_G_secp_uncomp, "\ncalc. result = " << result << "\nexp. result = " << exp_result << "\n"); + CHECK_MESSAGE(sv_result == sv_G_secp_uncomp, "calc. result = " << result << "\nexp. result = " << exp_result); return fails; } @@ -793,7 +793,7 @@ size_t test_mult_sec_mass() } catch(std::exception& e) { - std::cout << "test_mult_sec_mass failed: " << e.what() << "\n"; + std::cout << "test_mult_sec_mass failed: " << e.what() << std::endl; ++fails; } } @@ -893,7 +893,7 @@ size_t ecc_randomized_test() } catch(std::exception& e) { - std::cout << "Testing " << group_name << " failed: " << e.what() << "\n"; + std::cout << "Testing " << group_name << " failed: " << e.what() << std::endl; ++fails; } } diff --git a/src/tests/unit_ecdh.cpp b/src/tests/unit_ecdh.cpp index fafb61b46..8018bb8da 100644 --- a/src/tests/unit_ecdh.cpp +++ b/src/tests/unit_ecdh.cpp @@ -23,8 +23,8 @@ using namespace Botan; -#define CHECK_MESSAGE(expr, print) try { if(!(expr)) { ++fails; std::cout << print << "\n"; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << "\n"; } -#define CHECK(expr) try { if(!(expr)) { ++fails; std::cout << #expr << "\n"; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << "\n"; } +#define CHECK_MESSAGE(expr, print) try { if(!(expr)) { ++fails; std::cout << print << std::endl; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << std::endl; } +#define CHECK(expr) try { if(!(expr)) { ++fails; std::cout << #expr << std::endl; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << std::endl; } namespace { @@ -46,9 +46,9 @@ size_t test_ecdh_normal_derivation(RandomNumberGenerator& rng) if(alice_key != bob_key) { - std::cout << "The two keys didn't match!\n"; - std::cout << "Alice's key was: " << alice_key.as_string() << "\n"; - std::cout << "Bob's key was: " << bob_key.as_string() << "\n"; + std::cout << "The two keys didn't match!" << std::endl; + std::cout << "Alice's key was: " << alice_key.as_string() << std::endl; + std::cout << "Bob's key was: " << bob_key.as_string() << std::endl; ++fails; } diff --git a/src/tests/unit_ecdsa.cpp b/src/tests/unit_ecdsa.cpp index ccbd168c7..39e656636 100644 --- a/src/tests/unit_ecdsa.cpp +++ b/src/tests/unit_ecdsa.cpp @@ -29,8 +29,8 @@ using namespace Botan; #define ECC_TEST_DATA_DIR TEST_DATA_DIR "/ecc" -#define CHECK_MESSAGE(expr, print) try { if(!(expr)) { ++fails; std::cout << print << "\n"; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << "\n"; } -#define CHECK(expr) try { if(!(expr)) { ++fails; std::cout << #expr << "\n"; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << "\n"; } +#define CHECK_MESSAGE(expr, print) try { if(!(expr)) { ++fails; std::cout << print << std::endl; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << std::endl; } +#define CHECK(expr) try { if(!(expr)) { ++fails; std::cout << #expr << std::endl; } } catch(std::exception& e) { std::cout << __FUNCTION__ << ": " << e.what() << std::endl; } namespace { @@ -92,7 +92,7 @@ size_t test_hash_larger_than_n(RandomNumberGenerator& rng) // verify against EMSA1_BSI if(pk_verifier.verify_message(message, signature)) { - std::cout << "Corrupt ECDSA signature verified, should not have\n"; + std::cout << "Corrupt ECDSA signature verified, should not have" << std::endl; ++fails; } @@ -160,7 +160,7 @@ size_t test_sign_then_ver(RandomNumberGenerator& rng) if(!ok) { - std::cout << "ERROR: Could not verify ECDSA signature\n"; + std::cout << "ERROR: Could not verify ECDSA signature" << std::endl; fails++; } @@ -169,7 +169,7 @@ size_t test_sign_then_ver(RandomNumberGenerator& rng) if(ok) { - std::cout << "ERROR: Bogus ECDSA signature verified anyway\n"; + std::cout << "ERROR: Bogus ECDSA signature verified anyway" << std::endl; fails++; } @@ -225,7 +225,7 @@ size_t test_ec_sign(RandomNumberGenerator& rng) } catch (std::exception& e) { - std::cout << "Exception in test_ec_sign - " << e.what() << "\n"; + std::cout << "Exception in test_ec_sign - " << e.what() << std::endl; ++fails; } @@ -241,7 +241,7 @@ size_t test_create_pkcs8(RandomNumberGenerator& rng) { RSA_PrivateKey rsa_key(rng, 1024); //RSA_PrivateKey rsa_key2(1024); - //cout << "\nequal: " << (rsa_key == rsa_key2) << "\n"; + //cout << "\nequal: " << (rsa_key == rsa_key2) << std::endl; //DSA_PrivateKey key(DL_Group("dsa/jce/1024")); std::ofstream rsa_priv_key(ECC_TEST_DATA_DIR "/rsa_private.pkcs8.pem"); @@ -314,7 +314,7 @@ size_t test_create_and_verify(RandomNumberGenerator& rng) if(!dynamic_cast<ECDSA_PrivateKey*>(loaded_key.get())) { - std::cout << "Failed to reload an ECDSA key with unusual parameter set\n"; + std::cout << "Failed to reload an ECDSA key with unusual parameter set" << std::endl; ++fails; } @@ -372,13 +372,13 @@ size_t test_curve_registry(RandomNumberGenerator& rng) if(!verifier.verify_message(msg, sig)) { - std::cout << "Failed testing ECDSA sig for curve " << oids[i] << "\n"; + std::cout << "Failed testing ECDSA sig for curve " << oids[i] << std::endl; ++fails; } } catch(Invalid_Argument& e) { - std::cout << "Error testing curve " << oids[i] << " - " << e.what() << "\n"; + std::cout << "Error testing curve " << oids[i] << " - " << e.what() << std::endl; ++fails; } } @@ -408,7 +408,7 @@ size_t test_read_pkcs8(RandomNumberGenerator& rng) catch (std::exception& e) { ++fails; - std::cout << "Exception in test_read_pkcs8 - " << e.what() << "\n"; + std::cout << "Exception in test_read_pkcs8 - " << e.what() << std::endl; } try @@ -431,14 +431,14 @@ size_t test_read_pkcs8(RandomNumberGenerator& rng) std::unique_ptr<PKCS8_PrivateKey> loaded_key_withdp( PKCS8::load_key(ECC_TEST_DATA_DIR "/withdompar_private.pkcs8.pem", rng)); - std::cout << "Unexpected success: loaded key with unknown OID\n"; + std::cout << "Unexpected success: loaded key with unknown OID" << std::endl; ++fails; } catch (std::exception) { /* OK */ } } catch (std::exception& e) { - std::cout << "Exception in test_read_pkcs8 - " << e.what() << "\n"; + std::cout << "Exception in test_read_pkcs8 - " << e.what() << std::endl; ++fails; } @@ -456,13 +456,13 @@ size_t test_ecc_key_with_rfc5915_extensions(RandomNumberGenerator& rng) if(!dynamic_cast<ECDSA_PrivateKey*>(pkcs8.get())) { - std::cout << "Loaded RFC 5915 key, but got something other than an ECDSA key\n"; + std::cout << "Loaded RFC 5915 key, but got something other than an ECDSA key" << std::endl; ++fails; } } catch(std::exception& e) { - std::cout << "Exception in " << BOTAN_CURRENT_FUNCTION << " - " << e.what() << "\n"; + std::cout << "Exception in " << BOTAN_CURRENT_FUNCTION << " - " << e.what() << std::endl; ++fails; } diff --git a/src/tests/unit_tls.cpp b/src/tests/unit_tls.cpp index f37bbe291..11ec049d5 100644 --- a/src/tests/unit_tls.cpp +++ b/src/tests/unit_tls.cpp @@ -86,7 +86,7 @@ class Credentials_Manager_Test : public Botan::Credentials_Manager } catch(std::exception& e) { - std::cout << "Certificate verification failed - " << e.what() << " - but will ignore\n"; + std::cout << "Certificate verification failed - " << e.what() << " - but will ignore" << std::endl; } } @@ -157,14 +157,14 @@ size_t basic_test_handshake(RandomNumberGenerator& rng, { if(session.version() != offer_version) std::cout << "Offered " << offer_version.to_string() - << " got " << session.version().to_string() << "\n"; + << " got " << session.version().to_string() << std::endl; return true; }; auto print_alert = [&](TLS::Alert alert, const byte[], size_t) { if(alert.is_valid()) - std::cout << "Server recvd alert " << alert.type_string() << "\n"; + std::cout << "Server recvd alert " << alert.type_string() << std::endl; }; auto save_server_data = [&](const byte buf[], size_t sz) @@ -179,9 +179,9 @@ size_t basic_test_handshake(RandomNumberGenerator& rng, auto next_protocol_chooser = [&](std::vector<std::string> protos) { if(protos.size() != 2) - std::cout << "Bad protocol size\n"; + std::cout << "Bad protocol size" << std::endl; if(protos[0] != "test/1" || protos[1] != "test/2") - std::cout << "Bad protocol values\n"; + std::cout << "Bad protocol values" << std::endl; return "test/3"; }; const std::vector<std::string> protocols_offered = { "test/1", "test/2" }; @@ -218,7 +218,7 @@ size_t basic_test_handshake(RandomNumberGenerator& rng, if(server.is_active()) { if(server.next_protocol() != "test/3") - std::cout << "Wrong protocol " << server.next_protocol() << "\n"; + std::cout << "Wrong protocol " << server.next_protocol() << std::endl; server.send("2"); } @@ -236,7 +236,7 @@ size_t basic_test_handshake(RandomNumberGenerator& rng, } catch(std::exception& e) { - std::cout << "Server error - " << e.what() << "\n"; + std::cout << "Server error - " << e.what() << std::endl; break; } @@ -249,7 +249,7 @@ size_t basic_test_handshake(RandomNumberGenerator& rng, } catch(std::exception& e) { - std::cout << "Client error - " << e.what() << "\n"; + std::cout << "Client error - " << e.what() << std::endl; break; } @@ -257,7 +257,7 @@ size_t basic_test_handshake(RandomNumberGenerator& rng, { if(c2s_data[0] != '1') { - std::cout << "Error\n"; + std::cout << "Error" << std::endl; return 1; } } @@ -266,7 +266,7 @@ size_t basic_test_handshake(RandomNumberGenerator& rng, { if(s2c_data[0] != '2') { - std::cout << "Error\n"; + std::cout << "Error" << std::endl; return 1; } } diff --git a/src/tests/unit_x509.cpp b/src/tests/unit_x509.cpp index 1e66cd655..2388dc920 100644 --- a/src/tests/unit_x509.cpp +++ b/src/tests/unit_x509.cpp @@ -121,7 +121,7 @@ u32bit check_against_copy(const Private_Key& orig, if(orig_id != pub_id || orig_id != priv_id || orig_id != priv_enc_id) { - std::cout << "Failed copy check for " << orig.algo_name() << "\n"; + std::cout << "Failed copy check for " << orig.algo_name() << std::endl; return 1; } return 0; |