mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-11-02 09:49:06 -06:00
[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:
1 parent
1cfda5a71a
commit
722a455593
2 files changed
+8
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user