Paul Beckingham
864b46a1b1
Unit Tests
...
- Improved two tests that always fail around summer time clock changes, by
eliminating the dependence on 86,400.
- Fixed feature.891.t tests that fail on certain fortuitous random UUID
permutations. Now hard-coded UUID.
2013-03-11 23:05:30 -04:00
Paul Beckingham
f4bfa1b2fd
Bug #995
...
- Fixed bug #995 , which mis-parsed UUIDs in filters as other elements (thanks
to Bryce Harrington).
- Nibbler no longer permits 8-character UUID abbreviations, because too often
they resemble other forms, such as '1111111d' which looks like a duration.
- Modified unit tests accordingly.
2012-04-29 00:28:28 -04:00
Paul Beckingham
7a45db4d0f
Feature #891
...
- Added feature #891 , which allows for leftmost partial matches of UUID values.
Makes direct comparisons for full-length values, and regular expressions for
partial values. Note that there is a minimum length of 8 hex digits.
- Added safety parsing mechanism that fails a partial UUID if immediately
followed by a hex digit. This allows for numbers longer than 8 digits to not
be misinterpreted as a UUID.
- Implemented Nibbler::getPartialUUID.
- Implemented unit tests.
@@ -1145,12 +1145,23 @@ const A3 A3::sequence (const A3& input) const
for (unsigned int i = 0; i < uuids.size (); ++i)
{
- if (ids.size ())
+ if (ids.size () + i > 0)
sequenced.push_back (Arg ("or", Arg::cat_op));
- sequenced.push_back (Arg ("uuid", Arg::type_string, Arg::cat_dom));
- sequenced.push_back (Arg ("=", Arg::cat_op));
- sequenced.push_back (Arg (uuids[i], Arg::type_string, Arg::cat_literal));
+ // A full-length UUID requires a string comparison.
+ if (uuids[i].length () == 36)
+ {
+ sequenced.push_back (Arg ("uuid", Arg::type_string, Arg::cat_dom));
+ sequenced.push_back (Arg ("=", Arg::cat_op));
+ sequenced.push_back (Arg (uuids[i], Arg::type_string, Arg::cat_literal));
+ }
+ // A UUID fragment is a leftmost comparison.
+ else
+ {
+ sequenced.push_back (Arg ("uuid", Arg::type_string, Arg::cat_dom));
+ sequenced.push_back (Arg ("~", Arg::cat_op));
+ sequenced.push_back (Arg ("^" + uuids[i], Arg::type_string, Arg::cat_rx));
+ }
}
sequenced.push_back (Arg (")", Arg::cat_op));
@@ -1674,11 +1685,11 @@ bool A3::is_uuid (Nibbler& n, std::string& result)
n.save ();
result = "";
std::string uuid;
- if (n.getUUID (uuid))
+ if (n.getPartialUUID (uuid))
{
result += uuid;
while (n.skip (',') &&
- n.getUUID (uuid))
+ n.getPartialUUID (uuid))
{
result += ',' + uuid;
}
@@ -1997,13 +2008,13 @@ bool A3::extract_uuid (
Nibbler n (input);
std::string uuid;
- if (n.getUUID (uuid))
+ if (n.getPartialUUID (uuid))
{
sequence.push_back (uuid);
while (n.skip (','))
{
- if (!n.getUUID (uuid))
+ if (!n.getPartialUUID (uuid))
throw std::string (STRING_A3_UUID_AFTER_COMMA);
sequence.push_back (uuid);
2012-02-19 22:27:40 -05:00