XCTAssertEqual macro no longer accepts CGPoint in Xcode 5.1
| Originator: | combinatorial | ||
| Number: | rdar://16281876 | Date Originated: | 3/10/2014 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | XCode 5.1 |
| Classification: | Reproducible: | Always |
Summary:
This code worked before v5.1 of Xcode:
CGPoint p1 = CGPointMake(1,2);
CGPoint p2 = CGPointMake(2,3);
XCTAssertEqual(p1, p2, @"Points not equal");
And in Xcode gives the error:
Invalid operands to binary expression ('typeof (p1)' (aka 'struct CGPoint') and 'typeof (p2)' (aka 'struct CGPoint'))
This is because the macro has changed an is doing a != comparison on the arguments which is invalid for a struct.
Steps to Reproduce:
1. See code in description.
Expected Results:
XCTAssertEqual works for CGPoint (and other structs supported by NSValue)
Actual Results:
Compilation fails.
Version:
XCode 5.1 (5B130a)
Notes:
Workaround is to use:
XCTAssertEqualObjects([NSValue valueWithCGPoint:p1],
[NSValue valueWithCGPoint:p2],
@"Points not equal");
Configuration:
OSX Mavericks
ios 7.1
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
You could always use something like XCTAssertTrue(CGPointEqualToPoint(p1,p2), points not equal);
You probably shouldn't be comparing points directly with == anyway, hence the helper function.