1 | #include <gtest/gtest.h> |
2 | |
3 | #include <engine/shared/uuid_manager.h> |
4 | |
5 | TEST(Uuid, FromToString) |
6 | { |
7 | char aUuid[UUID_MAXSTRSIZE]; |
8 | CUuid Uuid; |
9 | EXPECT_FALSE(ParseUuid(&Uuid, "8d300ecf-5873-4297-bee5-95668fdff320" )); |
10 | FormatUuid(Uuid, pBuffer: aUuid, BufferLength: sizeof(aUuid)); |
11 | EXPECT_STREQ(aUuid, "8d300ecf-5873-4297-bee5-95668fdff320" ); |
12 | EXPECT_FALSE(ParseUuid(&Uuid, "00000000-0000-0000-0000-000000000000" )); |
13 | FormatUuid(Uuid, pBuffer: aUuid, BufferLength: sizeof(aUuid)); |
14 | EXPECT_STREQ(aUuid, "00000000-0000-0000-0000-000000000000" ); |
15 | EXPECT_FALSE(ParseUuid(&Uuid, "ffffffff-ffff-ffff-ffff-ffffffffffff" )); |
16 | FormatUuid(Uuid, pBuffer: aUuid, BufferLength: sizeof(aUuid)); |
17 | EXPECT_STREQ(aUuid, "ffffffff-ffff-ffff-ffff-ffffffffffff" ); |
18 | EXPECT_FALSE(ParseUuid(&Uuid, "01234567-89aB-cDeF-0123-456789AbCdEf" )); |
19 | FormatUuid(Uuid, pBuffer: aUuid, BufferLength: sizeof(aUuid)); |
20 | EXPECT_STREQ(aUuid, "01234567-89ab-cdef-0123-456789abcdef" ); |
21 | } |
22 | |
23 | TEST(Uuid, ParseFailures) |
24 | { |
25 | CUuid Uuid; |
26 | EXPECT_TRUE(ParseUuid(&Uuid, "" )); |
27 | EXPECT_TRUE(ParseUuid(&Uuid, "01234567-89ab-cdef-0123-456789abcdeg" )); |
28 | EXPECT_TRUE(ParseUuid(&Uuid, "0-0-0-0-0" )); |
29 | EXPECT_TRUE(ParseUuid(&Uuid, "01234567-89ab-cdef-0123-456789abcde" )); |
30 | EXPECT_TRUE(ParseUuid(&Uuid, "01234567-89ab-cdef-0123-456789abcdef0" )); |
31 | EXPECT_TRUE(ParseUuid(&Uuid, "01234567+89ab-cdef-0123-456789abcdef" )); |
32 | EXPECT_TRUE(ParseUuid(&Uuid, "01234567-89ab+cdef-0123-456789abcdef" )); |
33 | EXPECT_TRUE(ParseUuid(&Uuid, "01234567-89ab-cdef+0123-456789abcdef" )); |
34 | EXPECT_TRUE(ParseUuid(&Uuid, "01234567-89ab-cdef-0123+456789abcdef" )); |
35 | EXPECT_TRUE(ParseUuid(&Uuid, "01234567-89ab-cdef-0123-456789abcdef " )); |
36 | EXPECT_TRUE(ParseUuid(&Uuid, "0x01234567-89ab-cdef-0123-456789abcdef" )); |
37 | } |
38 | |