Found another case in which comparing nil to nil was leading to a failing
test; ultimately the +[NSValue WOTest_compare:] method was being called where
both objects were encoded with type "pointer-to-void".
This commit adds a special case for such comparisons: truly equal pointers are
considered to be NSOrderedSame; all others fall through to the default path
and an exception is raised.
This is a conservative approach because in reality the only kind of pointer
comparison which makes sense in practice is an equality test, not an ordering
test.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
[NSException raise:NSInvalidArgumentException format:@"compared objects must be of same class and implement compare:"];
}
+ // pointer-to-void case
+ if ([self WOTest_isPointerToVoid] && [aValue WOTest_isPointerToVoid])
+ {
+ // test conservatively here: equal pointers are considered equal;
+ // all others fall through and an exception is raised
+ if ([self pointerValue] == [aValue pointerValue])
+ return NSOrderedSame;
+ }
+
// numeric scalar case
if ([self WOTest_isNumericScalar] && [aValue WOTest_isNumericScalar])
{