From 9a8b4a80240dc25f0547a76b9bd1054d7e307402 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 8 Sep 2018 21:52:14 -0400 Subject: [PATCH] Make TestStringSink a debug test --- validat0.cpp | 22 ++++++++++++++++++++++ validat3.cpp | 23 ++--------------------- validate.h | 3 ++- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/validat0.cpp b/validat0.cpp index eafaf86d..62e5ec30 100644 --- a/validat0.cpp +++ b/validat0.cpp @@ -1488,5 +1488,27 @@ bool TestASN1Parse() } #endif +#if defined(CRYPTOPP_EXTENDED_VALIDATION) +bool TestStringSink() +{ + try + { + std::string in = "The quick brown fox jumps over the lazy dog"; + + std::string str; + StringSource s1(in, true, new StringSink(str)); + + std::vector vec; + StringSource s2(in, true, new VectorSink(vec)); + + return str.size() == vec.size() && std::equal(str.begin(), str.end(), vec.begin()); + } + catch(const std::exception&) + { + } + return false; +} +#endif + NAMESPACE_END // Test NAMESPACE_END // CryptoPP diff --git a/validat3.cpp b/validat3.cpp index fc658501..ad9660aa 100644 --- a/validat3.cpp +++ b/validat3.cpp @@ -41,7 +41,6 @@ bool ValidateAll(bool thorough) { bool pass=TestSettings(); pass=TestOS_RNG() && pass; - pass=TestStringSink() && pass; pass=TestRandomPool() && pass; #if !defined(NO_OS_DEPENDENCE) && defined(OS_RNG_AVAILABLE) pass=TestAutoSeededX917() && pass; @@ -70,6 +69,8 @@ bool ValidateAll(bool thorough) pass=TestHuffmanCodes() && pass; // http://github.com/weidai11/cryptopp/issues/346 pass=TestASN1Parse() && pass; + // https://github.com/weidai11/cryptopp/pull/334 + pass=TestStringSink() && pass; // Always part of the self tests; call in Debug # if defined(CRYPTOPP_ALTIVEC_AVAILABLE) pass=TestAltivecOps() && pass; @@ -562,26 +563,6 @@ bool TestOS_RNG() return pass; } -bool TestStringSink() -{ - try - { - std::string in = "The quick brown fox jumps over the lazy dog"; - - std::string str; - StringSource s1(in, true, new StringSink(str)); - - std::vector vec; - StringSource s2(in, true, new VectorSink(vec)); - - return str.size() == vec.size() && std::equal(str.begin(), str.end(), vec.begin()); - } - catch(...) - { - } - return false; -} - bool TestRandomPool() { std::cout << "\nTesting RandomPool generator...\n\n"; diff --git a/validate.h b/validate.h index b11afb4d..246686bc 100644 --- a/validate.h +++ b/validate.h @@ -23,7 +23,6 @@ NAMESPACE_BEGIN(Test) bool ValidateAll(bool thorough); bool TestSettings(); bool TestOS_RNG(); -bool TestStringSink(); // bool TestSecRandom(); bool TestRandomPool(); #if !defined(NO_OS_DEPENDENCE) @@ -150,6 +149,8 @@ bool TestRounding(); bool TestHuffmanCodes(); // http://github.com/weidai11/cryptopp/issues/346 bool TestASN1Parse(); +// https://github.com/weidai11/cryptopp/pull/334 +bool TestStringSink(); // Additional tests due to no coverage bool TestCompressors(); bool TestEncryptors();