XCTAssertEqual error: (“3”) is not equal to (“3”)

后端 未结 5 1839
遇见更好的自我
遇见更好的自我 2020-12-30 19:11
NSMutableArray *arr = [NSMutableArray array];
[arr addObject:@\"1\"];
[arr addObject:@\"2\"];
[arr addObject:@\"3\"];

// This statement is fine.
XCTAssertTrue(arr.c         


        
5条回答
  •  滥情空心
    2020-12-30 19:33

    I got snagged by this issue as well, very thankful for the workarounds provided here. Quick FYI, it seems this was fixed in Xcode 5.1 release.

    https://developer.apple.com/library/mac/releasenotes/DeveloperTools/RN-Xcode/xc5_release_notes/xc5_release_notes.html

    The XCTAssertEqual macro (formerly STAssertEquals using OCUnit) correctly compares scalar values of different types without casting, for example, int and NSInteger. It can no longer accept nonscalar types, such as structs, for comparison. (14435933)

    I have not yet upgraded from Xcode 5.0.2 but my colleague has, and the same XC tests that were previously failing due to this problem are now passing without the casting workaround.

提交回复
热议问题