[guid.cpp] string->guid should disallow 'g' char

off-by-1 error in alpha test. only 'a'-'f' should be allowed.
This commit is contained in:
Christopher Lam committed 2025-11-30 20:51:33 +08:00
1 parent 1cfda5a71a
commit 722a455593
2 files changed
+8 -1

No files matched your search

+1 -1
View File
@@ -92,7 +92,7 @@ char_to_num (unsigned char c) noexcept
{
unsigned int digit = c - '0';
unsigned int alpha = (c | 0x20) - 'a';
return digit <= 9 ? digit : alpha <= 6 ? alpha + 10 : -1;
return digit <= 9 ? digit : alpha <= 5 ? alpha + 10 : -1;
}
static inline bool
+7
View File
@@ -74,6 +74,13 @@ TEST (GncGUID, from_string)
guid = gnc::GUID::create_random ();
std::string bogus {"Have a great big roast beef sandwich, if you please!"};
EXPECT_THROW (gnc::GUID::from_string (bogus), gnc::guid_syntax_exception);
std::string test1 {"0123456789abcdef0123456789abcdef"};
auto guid1 = gnc::GUID::from_string (test1);
EXPECT_EQ (test1, guid1.to_string());
std::string test2 {"0123456789abcdef0123456789abcdeg"};
EXPECT_THROW (gnc::GUID::from_string (test2), gnc::guid_syntax_exception);
}
TEST (GncGUID, round_trip)