aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/uid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/uid.cpp')
-rw-r--r--src/zencore/uid.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/zencore/uid.cpp b/src/zencore/uid.cpp
index 971683721..a7e68acb2 100644
--- a/src/zencore/uid.cpp
+++ b/src/zencore/uid.cpp
@@ -3,6 +3,7 @@
#include <zencore/uid.h>
#include <zencore/endian.h>
+#include <zencore/oidguid.h>
#include <zencore/string.h>
#include <zencore/testing.h>
@@ -187,6 +188,24 @@ TEST_CASE("Oid")
}
}
+TEST_CASE("OidGuid roundtrip")
+{
+ // Lossless in the Oid -> Guid -> Oid direction by construction —
+ // see oidguid.h. The version (4) and variant (10xx) markers in the
+ // produced Guid mean it's also a syntactically valid v4 UUID.
+ for (int Iteration = 0; Iteration < 1000; ++Iteration)
+ {
+ Oid Original = Oid::NewOid();
+ Guid AsGuid = OidToGuid(Original);
+ Oid Restored = GuidToOid(AsGuid);
+ CHECK(Restored == Original);
+
+ // Version and variant bits should always be set.
+ CHECK((AsGuid.B & 0x0000F000u) == 0x00004000u);
+ CHECK((AsGuid.C & 0xC0000000u) == 0x80000000u);
+ }
+}
+
TEST_SUITE_END();
void