summaryrefslogtreecommitdiff
path: root/validat3.cpp
diff options
context:
space:
mode:
authororangefour <orange@four>2018-09-05 09:25:09 +0200
committerorangefour <orange@four>2018-09-05 09:25:09 +0200
commit9b81a545fc50b13f933687550ef116818ab29de6 (patch)
tree17510a45d4ce1912b18debebc17f3b80e4a680ce /validat3.cpp
parent44cd7eb1ed8460d4b6471101c67a78ca9e1ae44d (diff)
downloadcryptopp-git-9b81a545fc50b13f933687550ef116818ab29de6.tar.gz
Add VectorSink
Diffstat (limited to 'validat3.cpp')
-rw-r--r--validat3.cpp21
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";