diff --git a/include/uuid.h b/include/uuid.h index 0cfa262..baed962 100644 --- a/include/uuid.h +++ b/include/uuid.h @@ -102,7 +102,7 @@ namespace uuids return uuid_variant::future; } - constexpr uuid_version version() const + constexpr uuid_version version() const noexcept { if ((data[6] & 0xF0) == 0x10) return uuid_version::time_based; diff --git a/test/test.cpp b/test/test.cpp index c1c1852..a1a2b20 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -21,9 +21,16 @@ int main() using namespace std::string_literals; - auto str = "47183823-2574-4bfd-b411-99ed177d3e43"s; - uuid guid(str); - assert(guid.string() == str); + { + auto str = "47183823-2574-4bfd-b411-99ed177d3e43"s; + uuid guid(str); + assert(guid.string() == str); + } + + { + uuid guid("47183823-2574-4bfd-b411-99ed177d3e43"); + assert(guid.string() == "47183823-2574-4bfd-b411-99ed177d3e43"s); + } } { @@ -36,6 +43,39 @@ int main() assert(guid.wstring() == str); } + { + std::cout << "Test std::array constructor" << std::endl; + + std::array arr{ + 0x47, 0x18, 0x38, 0x23, + 0x25, 0x74, + 0x4b, 0xfd, + 0xb4, 0x11, + 0x99, 0xed, 0x17, 0x7d, 0x3e, 0x43 + }; + + using namespace std::string_literals; + + uuid guid(arr); + assert(guid.string() == "47183823-2574-4bfd-b411-99ed177d3e43"s); + } + + { + std::cout << "Test array constructor" << std::endl; + + using namespace std::string_literals; + + uint8_t arr[16] = { + 0x47, 0x18, 0x38, 0x23, + 0x25, 0x74, + 0x4b, 0xfd, + 0xb4, 0x11, + 0x99, 0xed, 0x17, 0x7d, 0x3e, 0x43 + }; + uuid guid(arr); + assert(guid.string() == "47183823-2574-4bfd-b411-99ed177d3e43"s); + } + { std::cout << "Test make" << std::endl;