XCTAssertEquals does not accept array literals
| Originator: | thomas | ||
| Number: | rdar://14504007 | Date Originated: | 21-Jul-2013 10:43 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | iOS 7 beta 3 |
| Classification: | Reproducible: | Yes |
Summary:
XCTAssertEquals first and second parameter cannot be an array literal, e.g.:
XCTAssertEquals(array2, @[@2,@3,@4,@5], @"Map result was not as expected");
does not work because of several compile errors.
Steps to Reproduce:
Create a XCTAssertEquals statement with an array literal as the first or second parameter.
Expected Results:
The XCTAssertEquals should compile correctly.
Actual Results:
Several compile errors:
- Expected identifier or '('
- Extraneous closing brace ('}')
- Unexpected '@' in program
- Extraneous closing brace ('}')
- Expected ']' or ','
- Unexpected token after Objective-C string
Regression:
No.
Notes:
I understand that this happens because XCTAssertEquals is a macro and results in several lines of code that will be compiled. When I enclose the array literal in parenthesis, I get the expected result. My suggestion is that you add the parenthesis in the macro realization.
This bug is also present in the other XCTAssert macros (I tested XCTAssertEqualObjects and XCTAssertEqualsNil as well).
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!