Last active
December 12, 2015 09:19
-
-
Save justinwyer/4750154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation CardTest | |
- (void)testShouldKnowCardCannotMatchEmptyCardList { | |
Card *card = [Card new]; | |
NSArray *otherCards = [NSArray new]; | |
STAssertEquals(0, [card match:otherCards], @"Should not match empty card list."); | |
} | |
- (void)testShouldMatchCardWhenCardListContainsCardWithSameContent { | |
Card *card = [[Card alloc] initWithContents:@"Test Card"]; | |
Card *matchingCard = [[Card alloc] initWithContents:@"Test Card"]; | |
Card *differentCard = [[Card alloc] initWithContents:@"Different Test Card"]; | |
NSMutableArray *cards = [[NSMutableArray alloc] initWithObjects:differentCard, differentCard, matchingCard, nil]; | |
time_t seed = time(nil); | |
srandom(seed); | |
for (NSInteger index = cards.count - 1; index > 0; index--) { | |
NSInteger swapIndex = random() % index; | |
[cards exchangeObjectAtIndex:index withObjectAtIndex:swapIndex]; | |
} | |
int result = [card match:cards]; | |
STAssertEquals(1, result, [NSString stringWithFormat:@"Should match when matching card is in list. Random seed: %d", seed]); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment