我是 ocUnit 的新手,我正在尝试将 2 个数组与 STAssertTrue 方法和 == 进行比较。
下面的测试只是向被测系统(sut)询问数组作为回报
- (void) testParse {
SomeClassForTesting* sut = [[SomeClassForTesting alloc] init];
NSArray* result = [sut parseAndReturn];
NSArray* expected = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", @"4",nil];
STAssertTrue(result == expected, @"This test failed");
}
然后在我的生产代码中,我只是返回相同的数组
- (NSArray *)parseAndReturn
{
NSArray* x = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", @"4",nil];
return x;
}
然而,当测试运行时,我失败了。我应该如何比较这些对象以查看它们是否相同?
先感谢您