Created
August 24, 2018 03:26
-
-
Save brentalanmiller/e5f7ab88af695540b8068881ac3fa30f to your computer and use it in GitHub Desktop.
Boost UUID truncates long string UUIDs without error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <boost/uuid/uuid.hpp> | |
#include <boost/uuid/uuid_io.hpp> | |
#include <boost/uuid/string_generator.hpp> | |
int main() { | |
boost::uuids::string_generator gen; | |
boost::uuids::uuid u = {}; | |
std::string test1 = "5E6086E2-B30E-40FB-84EC-419EDCDD4DB1"; | |
std::string test2 = "D6FEDF2A-4B19-45C8-A040-A6CC2C206233-58886-000081F89D313161"; | |
try { | |
u = gen(test1); | |
} catch (const std::runtime_error &e) { | |
std::cerr << "Invalid UUID in test1. Got: " << test1 << std::endl; | |
} | |
std::cout << "parsed test1: " << to_string(u) << std::endl; | |
try { | |
u = gen(test2); | |
} catch (const std::runtime_error &e) { | |
std::cerr << "Invalid UUID in test2. Got: " << test2 << std::endl; | |
} | |
std::cout << "parsed test2: " << to_string(u) << std::endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parsed test1: 5e6086e2-b30e-40fb-84ec-419edcdd4db1 | |
parsed test2: d6fedf2a-4b19-45c8-a040-a6cc2c206233 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment