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/zencore/xxhash.cpp | |
| parent | changelog (diff) | |
| download | zen-8489bc54889a7da498764bfd30f12e1964c29140.tar.xz zen-8489bc54889a7da498764bfd30f12e1964c29140.zip | |
added xxhash unit tests (which currently fail)
Diffstat (limited to 'src/zencore/xxhash.cpp')
| -rw-r--r-- | src/zencore/xxhash.cpp | 41 |
1 files changed, 41 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 |