Skip to content

Instantly share code, notes, and snippets.

@jacksonh
Forked from bvanderveen/gist:3260382
Created August 5, 2012 23:13
Show Gist options
  • Save jacksonh/3267802 to your computer and use it in GitHub Desktop.
Save jacksonh/3267802 to your computer and use it in GitHub Desktop.
Objective-C assertion ideas
- (void) assertionIdeasLikeNUnit
{
[Assert that:@"foobar" is:[Equal to:@"other"]];
[Assert that:@"foobar" isNot:[Equal to:@"other"]];
[Assert that:collection isAll:[Less than:@10]];
[Assert that:collection isAll:[Less thanOrEqualTo:@10]];
[Assert that:collection isAll:[Less thanOrEqualTo:@10]];
[Assert that:collection isAll:[Greater than:@10]];
[Assert that:collection isAll:[Greater thanOrEqualTo:@10]];
[Assert that:collection isAll:[Greater thanOrEqualTo:@10]];
[Assert that:value is:[Less thanInteger:10]];
[Assert that:value is:[Less thanFloat:10f]];
[Assert that:value is:[Between low:@0 high:@10]];
[Assert that:value is:[Between low:lo high:hi using:comparer]];
// I think we can get away with some special Nil handling to make nil
// tests a little cleaner.
[Assert that:nil is:Nil];
[Assert that:@"not nil" isNot:Nil];
[Assert that:bool is:[Equal toNO]];
[Assert that:bool is:[Equal toYES]];
[Assert that:pointer1 is:[Same as:pointer2]];
[Assert that:object is:[Kind of:[Foo class]]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment