Make TestStringSink a debug test

pull/723/head
Jeffrey Walton 2018-09-08 21:52:14 -04:00
parent ae34c2d2ff
commit 9a8b4a8024
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
3 changed files with 26 additions and 22 deletions

View File

@ -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<byte> 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

View File

@ -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<byte> 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";

View File

@ -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();