aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_hash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/test_hash.cpp')
-rw-r--r--src/tests/test_hash.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/tests/test_hash.cpp b/src/tests/test_hash.cpp
index 242988c80..fb8d54e1f 100644
--- a/src/tests/test_hash.cpp
+++ b/src/tests/test_hash.cpp
@@ -42,9 +42,11 @@ size_t hash_test(const std::string& algo,
continue;
}
+ const std::vector<byte> in = hex_decode(in_hex);
+
std::unique_ptr<HashFunction> hash(proto->clone());
- hash->update(hex_decode(in_hex));
+ hash->update(in);
auto h = hash->final();
@@ -58,7 +60,7 @@ size_t hash_test(const std::string& algo,
hash->update("some discarded input");
hash->clear();
- hash->update(hex_decode(in_hex));
+ hash->update(in);
h = hash->final();
@@ -68,6 +70,20 @@ size_t hash_test(const std::string& algo,
<< " (with discarded input)\n";
++fails;
}
+
+ if(in.size() > 1)
+ {
+ hash->update(in[0]);
+ hash->update(&in[1], in.size() - 1);
+ h = hash->final();
+
+ if(h != hex_decode_locked(out_hex))
+ {
+ std::cout << algo << " " << provider << " got " << hex_encode(h) << " != " << out_hex
+ << " (with offset input)\n";
+ ++fails;
+ }
+ }
}
return fails;