I'm new to ocUnit and I'm attempting to compare 2 arrays with the STAssertTrue method and == for equality.
The test below simply asks the system under test (sut) for the array in return
- (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");
}
Then inside my production code I simply return the same array
- (NSArray *)parseAndReturn
{
NSArray* x = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", @"4",nil];
return x;
}
Yet when the test runs I get a failure. How should I compare these objects to see if they are the same or not?
Thank you in advance