aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_hash.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-05-22 13:31:37 -0400
committerJack Lloyd <[email protected]>2017-05-22 13:31:37 -0400
commitf2f2fe7610f196cd4c5f51b5e588558762448d3c (patch)
tree70f0f84ea8c0659387e6726493a3065d05adcfe1 /src/tests/test_hash.cpp
parent89e6af6b94de14a4325d6f761b1bf597b6eb450f (diff)
Add HashFunction::copy_state
See GH #1037
Diffstat (limited to 'src/tests/test_hash.cpp')
-rw-r--r--src/tests/test_hash.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/tests/test_hash.cpp b/src/tests/test_hash.cpp
index 9c6051f49..9ac3e7d4e 100644
--- a/src/tests/test_hash.cpp
+++ b/src/tests/test_hash.cpp
@@ -69,11 +69,19 @@ class Hash_Function_Tests : public Text_Based_Test
result.test_eq(provider, "hashing after clear", hash->final(), expected);
// TODO: feed in random pieces to fully test buffering
- if(input.size() > 1)
+ if(input.size() > 5)
{
hash->update(input[0]);
+
+ std::unique_ptr<Botan::HashFunction> fork = hash->copy_state();
+ // verify fork copy doesn't affect original computation
+ fork->update(&input[1], input.size() - 2);
+
hash->update(&input[1], input.size() - 1);
result.test_eq(provider, "hashing split", hash->final(), expected);
+
+ fork->update(&input[input.size() - 1], 1);
+ result.test_eq(provider, "hashing split", fork->final(), expected);
}
if(hash->hash_block_size() > 0)