From 1a342f8faee21c4ce71a415c90513683ff9d6cd7 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 30 Jul 2015 16:30:24 +0200 Subject: [PATCH] Added stream test --- tests/crypto/sha_tests.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/crypto/sha_tests.cpp b/tests/crypto/sha_tests.cpp index 056bf61..850c2f8 100644 --- a/tests/crypto/sha_tests.cpp +++ b/tests/crypto/sha_tests.cpp @@ -73,12 +73,27 @@ void test_big( const std::string& expected ) { BOOST_CHECK( hash3 == hash2 << 60 ); } +template +void test_stream( ) { + H hash( TEST1 ); + std::stringstream stream; + stream << hash; + + H other; + stream >> other; + BOOST_CHECK( hash == other ); +} + template void test_big( const std::string& expected ); template void test_big( const std::string& expected ); template void test_big( const std::string& expected ); template void test_big( const std::string& expected ); template void test_big( const std::string& expected ); +template void test_stream(); +template void test_stream(); +template void test_stream(); + BOOST_AUTO_TEST_SUITE(fc_crypto) BOOST_AUTO_TEST_CASE(ripemd160_test) @@ -90,6 +105,7 @@ BOOST_AUTO_TEST_CASE(ripemd160_test) // test( TEST4, "" ); test( TEST5, "52783243c1697bdbe16d37f97f68f08325dc1528" ); test_big( "29b6df855772aa9a95442bf83b282b495f9f6541" ); + test_stream(); } BOOST_AUTO_TEST_CASE(sha1_test) @@ -123,6 +139,7 @@ BOOST_AUTO_TEST_CASE(sha256_test) test( TEST4, "cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1" ); test( TEST5, "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" ); test_big( "50e72a0e26442fe2552dc3938ac58658228c0cbfb1d2ca872ae435266fcd055e" ); + test_stream(); std::vector test_object; test_object.push_back( 42 ); @@ -155,6 +172,7 @@ BOOST_AUTO_TEST_CASE(sha512_test) "de0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b" ); test_big( "b47c933421ea2db149ad6e10fce6c7f93d0752380180ffd7f4629a712134831d" "77be6091b819ed352c2967a2e2d4fa5050723c9630691f1a05a7281dbe6c1086" ); + test_stream(); } BOOST_AUTO_TEST_SUITE_END()