Skip to content

Commit f280e2b

Browse files
Make work with types
1 parent 7adc7bb commit f280e2b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/util/serialise/xxhash.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace util {
4747
uint32_t xxhash32(const T& input, const uint32_t& seed = 0) {
4848
return xxhash32(reinterpret_cast<const char*>(&input), sizeof(T), seed);
4949
}
50-
template <typename T, size_t N>
50+
template <size_t N>
5151
uint32_t xxhash32(const char (&input)[N], const uint32_t& seed = 0) {
5252
return xxhash32(input, N - 1, seed);
5353
}

tests/tests/util/serialise/xxhash.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,18 @@ namespace util {
207207
WHEN("xxhash32 is called with a string literal") {
208208
THEN("it matches the expected seedless and seeded values (no NUL terminator)") {
209209
// Match with and without seed
210-
REQUIRE(xxhash32("FooBar") == xxhash32("FooBar", std::strlen("FooBar")));
211-
REQUIRE(xxhash32("FooBar", fixed_seed) == xxhash32("FooBar", std::strlen("FooBar"), fixed_seed));
210+
const char* str = "FooBar";
211+
CHECK(xxhash32("FooBar") == xxhash32(str, std::strlen(str)));
212+
CHECK(xxhash32("FooBar", fixed_seed) == xxhash32(str, std::strlen(str), fixed_seed));
212213
}
213214
}
214215

215216
WHEN("xxhash64 is called with a string literal") {
216217
THEN("it matches the expected seedless and seeded values (no NUL terminator)") {
217218
// Match with and without seed
218-
REQUIRE(xxhash64("FooBar") == xxhash64("FooBar", std::strlen("FooBar")));
219-
REQUIRE(xxhash64("FooBar", fixed_seed) == xxhash64("FooBar", std::strlen("FooBar"), fixed_seed));
219+
const char* str = "FooBar";
220+
CHECK(xxhash64("FooBar") == xxhash64(str, std::strlen(str)));
221+
CHECK(xxhash64("FooBar", uint64_t(fixed_seed)) == xxhash64(str, std::strlen(str), fixed_seed));
220222
}
221223
}
222224
}

0 commit comments

Comments
 (0)