diff options
author | orangefour <orange@four> | 2018-09-05 09:25:09 +0200 |
---|---|---|
committer | orangefour <orange@four> | 2018-09-05 09:25:09 +0200 |
commit | 9b81a545fc50b13f933687550ef116818ab29de6 (patch) | |
tree | 17510a45d4ce1912b18debebc17f3b80e4a680ce /validat3.cpp | |
parent | 44cd7eb1ed8460d4b6471101c67a78ca9e1ae44d (diff) | |
download | cryptopp-git-9b81a545fc50b13f933687550ef116818ab29de6.tar.gz |
Add VectorSink
Diffstat (limited to 'validat3.cpp')
-rw-r--r-- | validat3.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/validat3.cpp b/validat3.cpp index 3cc46615..fc658501 100644 --- a/validat3.cpp +++ b/validat3.cpp @@ -41,6 +41,7 @@ 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;
@@ -561,6 +562,26 @@ 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";
|