diff options
| author | Stefan Boberg <[email protected]> | 2024-12-13 11:58:13 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2024-12-13 11:58:13 +0100 |
| commit | 8489bc54889a7da498764bfd30f12e1964c29140 (patch) | |
| tree | edda2a993abfb7c0d8fdec444fa96487a9b5dd87 /src | |
| parent | changelog (diff) | |
| download | zen-8489bc54889a7da498764bfd30f12e1964c29140.tar.xz zen-8489bc54889a7da498764bfd30f12e1964c29140.zip | |
added xxhash unit tests (which currently fail)
Diffstat (limited to 'src')
| -rw-r--r-- | src/zencore/xxhash.cpp | 41 | ||||
| -rw-r--r-- | src/zencore/zencore.cpp | 5 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/zencore/xxhash.cpp b/src/zencore/xxhash.cpp index 450131d19..ff88a4372 100644 --- a/src/zencore/xxhash.cpp +++ b/src/zencore/xxhash.cpp @@ -47,4 +47,45 @@ XXH3_128::ToHexString(StringBuilderBase& OutBuilder) const return OutBuilder; } +////////////////////////////////////////////////////////////////////////// +// +// Unit tests +// + +#if ZEN_WITH_TESTS + +void +xxhash_forcelink() +{ +} + +TEST_CASE("XXH3_128") +{ + using namespace std::literals; + + const std::string_view ShortString{"1234"}; + const std::string_view LongString{ + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"}; + + SUBCASE("short") + { + XXH3_128Stream x; + x.Append(ShortString.data(), ShortString.size()); + const XXH3_128 Hash = x.GetHash(); + CHECK(Hash == XXH3_128::FromHexString("0d44dd7fde8ea2b4ba961e1a26f71f21"sv)); + } + + SUBCASE("long") + { + XXH3_128Stream x; + x.Append(LongString.data(), LongString.size()); + const XXH3_128 Hash = x.GetHash(); + CHECK(Hash == XXH3_128::FromHexString("bc408748826fb22da051517c97c9d181"sv)); + } +} + +#endif + } // namespace zen diff --git a/src/zencore/zencore.cpp b/src/zencore/zencore.cpp index e813a3e6c..db821bff8 100644 --- a/src/zencore/zencore.cpp +++ b/src/zencore/zencore.cpp @@ -36,6 +36,10 @@ #include <atomic> +namespace zen { +extern void xxhash_forcelink(); +} + namespace zen::assert { void @@ -264,6 +268,7 @@ zencore_forcelinktests() zen::cbjson_forcelink(); zen::cbyaml_forcelink(); zen::workthreadpool_forcelink(); + xxhash_forcelink(); } } // namespace zen |