diff --git a/deps/ox/src/ox/std/test/CMakeLists.txt b/deps/ox/src/ox/std/test/CMakeLists.txt index 85052f76..8914db50 100644 --- a/deps/ox/src/ox/std/test/CMakeLists.txt +++ b/deps/ox/src/ox/std/test/CMakeLists.txt @@ -22,3 +22,4 @@ add_test("[ox/std] StringSplit" StdTest "StringSplit") add_test("[ox/std] FromHex" StdTest "FromHex") add_test("[ox/std] ToHex" StdTest "ToHex") add_test("[ox/std] UUID" StdTest "UUID") +add_test("[ox/std] UUID::generate" StdTest "UUID::generate") diff --git a/deps/ox/src/ox/std/test/tests.cpp b/deps/ox/src/ox/std/test/tests.cpp index 61f2ec5c..f6c6f391 100644 --- a/deps/ox/src/ox/std/test/tests.cpp +++ b/deps/ox/src/ox/std/test/tests.cpp @@ -210,6 +210,16 @@ static std::map tests = { return OxError(0); } }, + { + "UUID::generate", + [] { + ox::UUID::seedGenerator({1234, 4321}); + oxExpect(ox::UUID::generate().unwrap().toString(), "c8f4bff1-d403-4576-fd3b-0c41f1cd8b7d"); + oxExpect(ox::UUID::generate().unwrap().toString(), "0d1b7dad-7d50-49b6-916d-c3d811b5af0a"); + oxExpect(ox::UUID::generate().unwrap().toString(), "e3889e0b-4dcd-47b2-b3eb-492ea958d3e4"); + return OxError(0); + } + }, { "StringSplit", [] { diff --git a/deps/ox/src/ox/std/uuid.cpp b/deps/ox/src/ox/std/uuid.cpp index 4e9c833f..df080d99 100644 --- a/deps/ox/src/ox/std/uuid.cpp +++ b/deps/ox/src/ox/std/uuid.cpp @@ -27,7 +27,8 @@ Result UUID::generate() noexcept { for (auto &v : out.m_value) { v = static_cast(s_rand.gen() % 255); } - out.m_value[6] = 4; + out.m_value[6] &= 0x0f; + out.m_value[6] |= 4 << 4; return out; }