You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many algorithms (e.g. std::sort) require a binary comparator to be a strict
weak ordering, or the program may crash or result in corrupted memory. It
would be very useful to provide a function template to verify that a
comparitor is a strict weak ordering:
VerifyStrictWeakOrdering(comp, values);
will test comp on the given collection of values. When a counter example
is found, the function will generate a failure and print the counter
example to help the user understand why comp is not an SWO. The time
complexity of this function may be O(N^2) where N is the number of values.
Original issue reported on code.google.com by [email protected] on 2 Nov 2009 at 9:22
The text was updated successfully, but these errors were encountered:
I have a solution almost finished that uses O(N) memory and
O(N^2) time. It has sit there fore 6 months and I just have to find
the time to give it the final touch! ;-)
My solution is implemented as a googlemock matcher, such that you can
easily compose the predicate with other predicates, e.g.
EXPECT_THAT(MyComparator(), IsSWO(some_array));
EXPECT_THAT(MyComparator(), AnyOf(IsSWO(some_array), HasSomeOtherProperty()));
I'm not sure if the generality for allowing composition is really
needed, but it's nice to have that option. ;-)
Original issue reported on code.google.com by
[email protected]
on 2 Nov 2009 at 9:22The text was updated successfully, but these errors were encountered: