summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2018-04-08 00:20:53 +0200
committerMattes D <github@xoft.cz>2018-04-08 00:20:53 +0200
commit1e312296cc8dca998dc854a2737c5bf9b2cfb407 (patch)
treea4db1c361e576a59bd5d15d87dc2bac0c434a25d
parentProperly destroy player (#4199) (diff)
downloadcuberite-1e312296cc8dca998dc854a2737c5bf9b2cfb407.tar
cuberite-1e312296cc8dca998dc854a2737c5bf9b2cfb407.tar.gz
cuberite-1e312296cc8dca998dc854a2737c5bf9b2cfb407.tar.bz2
cuberite-1e312296cc8dca998dc854a2737c5bf9b2cfb407.tar.lz
cuberite-1e312296cc8dca998dc854a2737c5bf9b2cfb407.tar.xz
cuberite-1e312296cc8dca998dc854a2737c5bf9b2cfb407.tar.zst
cuberite-1e312296cc8dca998dc854a2737c5bf9b2cfb407.zip
-rw-r--r--src/UUID.cpp2
-rw-r--r--tests/UUID/UUIDTest.cpp33
2 files changed, 32 insertions, 3 deletions
diff --git a/src/UUID.cpp b/src/UUID.cpp
index 866bf817e..c04e585d7 100644
--- a/src/UUID.cpp
+++ b/src/UUID.cpp
@@ -178,7 +178,7 @@ UInt8 cUUID::Version() const
UInt8 cUUID::Variant() const
{
- const Byte VariantBits = static_cast<Byte>((m_UUID[9] >> 5) & 0x07);
+ const Byte VariantBits = static_cast<Byte>((m_UUID[8] >> 5) & 0x07);
/* Variant bits format:
bits | variant | Description
diff --git a/tests/UUID/UUIDTest.cpp b/tests/UUID/UUIDTest.cpp
index abd9db8df..bcd8c09cb 100644
--- a/tests/UUID/UUIDTest.cpp
+++ b/tests/UUID/UUIDTest.cpp
@@ -10,7 +10,8 @@
/** Test that FromString -> ToShortString preserves the original value for short UUIDs. */
static void UUIDFromStringToShortString()
{
- const char TestStrings[][33]{
+ const char TestStrings[][33]
+ {
"0123456789abcdef0123456789ABCDEF",
"d188b2648cc311e7bb31be2e44b06b34",
"e760d270d8b34288b895d9f78a31e083",
@@ -38,7 +39,8 @@ static void UUIDFromStringToShortString()
/** Test that FromString -> ToLongString preserves the original value for long UUIDs. */
static void UUIDFromStringToLongString()
{
- const char TestStrings[][37]{
+ const char TestStrings[][37]
+ {
"01234567-89ab-cdef-0123-456789ABCDEF",
"d188b264-8cc3-11e7-bb31-be2e44b06b34",
"e760d270-d8b3-4288-b895-d9f78a31e083",
@@ -108,6 +110,30 @@ static void UUIDNil()
+/** Test that variant and version numbers are read correctly. */
+static void UUIDType()
+{
+ // From issue #4209
+ const char TestStrings[][33]
+ {
+ "31cfcbeea8f2324a86dbccb1d5aaa6f8",
+ "3f2e1dd234a03b6b824c5a0e74083b1e"
+ };
+
+ for (const auto & String : TestStrings)
+ {
+ cUUID UUID;
+ assert_test(UUID.FromString(String));
+ assert_test(UUID.Variant() == 1);
+ assert_test(UUID.Version() == 3);
+ }
+
+}
+
+
+
+
+
int main(int argc, char * argv[])
{
LOG("UUID tests started");
@@ -124,6 +150,9 @@ int main(int argc, char * argv[])
LOG("Testing nil UUIDs");
UUIDNil();
+ LOG("Testing UUID type information");
+ UUIDType();
+
LOG("UUID tests finished");
}