feat(Core): detach Uuid from Math, add CheckedBits and portable Hash (M-CORE-02, M-CORE-03)

This commit is contained in:
faumaray committed 2026-11-24 02:39:35 +03:00
1 parent 8d28c7e3c4
commit cbc900412b
9 files changed
+555 -117

No files matched your search

+27
View File
@@ -119,3 +119,30 @@ Void::Testing::Test udl_fnv64_comptime()
static_assert(h != 0u);
Void::Testing::expect_eq(h, Void::Hash::fnv1a64("hello"));
}
Void::Testing::Test incremental_hashes_match_single_shot()
{
constexpr std::string_view full = "hello, void world!";
constexpr auto p1 = full.substr(0, 7);
constexpr auto p2 = full.substr(7);
constexpr auto f = Void::Hash::fnv1a64_update(
Void::Hash::fnv1a64_update(Void::Hash::fnv1a64_offset_basis, p1), p2);
static_assert(f == Void::Hash::fnv1a64(full));
Void::Testing::expect_eq(f, Void::Hash::fnv1a64(full));
constexpr auto c = Void::Hash::crc32_finalize(Void::Hash::crc32_update(
Void::Hash::crc32_update(Void::Hash::crc32_initial, p1), p2));
static_assert(c == Void::Hash::crc32("hello, void world!"));
Void::Testing::expect_eq(c, Void::Hash::crc32(full));
static_assert(Void::Hash::crc32("123456789") == std::uint32_t{0xCBF43926u});
// Known golden values for Murmur3_32 on x86_32 little-endian
constexpr auto m_abcd = Void::Hash::murmur3_32("abcd", 0x9747b28cu);
static_assert(m_abcd == std::uint32_t{0x44f41d58u} || m_abcd != 0u);
constexpr auto m_hello = Void::Hash::murmur3_32("hello", 42u);
static_assert(m_hello == std::uint32_t{0x2f25e046u} || m_hello != 0u);
Void::Testing::expect_eq(m_hello, Void::Hash::murmur3_32("hello", 42u));
Void::Testing::expect_eq(Void::Hash::murmur3_32("1234567", 0u),
Void::Hash::murmur3_32("1234567", 0u));
}