[ox/std] Add test for UUID::generate() and fix bug
This commit is contained in:
parent
86a3bf1248
commit
777a6d54f0
1
deps/ox/src/ox/std/test/CMakeLists.txt
vendored
1
deps/ox/src/ox/std/test/CMakeLists.txt
vendored
@ -22,3 +22,4 @@ add_test("[ox/std] StringSplit" StdTest "StringSplit")
|
|||||||
add_test("[ox/std] FromHex" StdTest "FromHex")
|
add_test("[ox/std] FromHex" StdTest "FromHex")
|
||||||
add_test("[ox/std] ToHex" StdTest "ToHex")
|
add_test("[ox/std] ToHex" StdTest "ToHex")
|
||||||
add_test("[ox/std] UUID" StdTest "UUID")
|
add_test("[ox/std] UUID" StdTest "UUID")
|
||||||
|
add_test("[ox/std] UUID::generate" StdTest "UUID::generate")
|
||||||
|
10
deps/ox/src/ox/std/test/tests.cpp
vendored
10
deps/ox/src/ox/std/test/tests.cpp
vendored
@ -210,6 +210,16 @@ static std::map<ox::String, ox::Error(*)()> tests = {
|
|||||||
return OxError(0);
|
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",
|
"StringSplit",
|
||||||
[] {
|
[] {
|
||||||
|
3
deps/ox/src/ox/std/uuid.cpp
vendored
3
deps/ox/src/ox/std/uuid.cpp
vendored
@ -27,7 +27,8 @@ Result<UUID> UUID::generate() noexcept {
|
|||||||
for (auto &v : out.m_value) {
|
for (auto &v : out.m_value) {
|
||||||
v = static_cast<uint8_t>(s_rand.gen() % 255);
|
v = static_cast<uint8_t>(s_rand.gen() % 255);
|
||||||
}
|
}
|
||||||
out.m_value[6] = 4;
|
out.m_value[6] &= 0x0f;
|
||||||
|
out.m_value[6] |= 4 << 4;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user