Skip to content

Commit

Permalink
add failing test for predicate with bool property
Browse files Browse the repository at this point in the history
  • Loading branch information
mastohhh authored and pasin committed Jun 9, 2015
1 parent 9e0ab0e commit 6e412fc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Unit-Tests/IncrementalStore_Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ - (void) test_FetchWithPredicates {

NSDictionary *entry1 = @{
@"created_at": [NSDate new],
@"check": @YES,
@"text": @"This is a test for predicates. Möhre.",
@"text2": @"This is text2.",
@"number": [NSNumber numberWithInt:10],
Expand All @@ -825,6 +826,7 @@ - (void) test_FetchWithPredicates {
};
NSDictionary *entry2 = @{
@"created_at": [[NSDate new] dateByAddingTimeInterval:-60],
@"check": @YES,
@"text": @"Entry number 2. touché.",
@"text2": @"Text 2 by Entry number 2",
@"number": [NSNumber numberWithInt:20],
Expand All @@ -833,6 +835,7 @@ - (void) test_FetchWithPredicates {
};
NSDictionary *entry3 = @{
@"created_at": [[NSDate new] dateByAddingTimeInterval:60],
@"check": @NO,
@"text": @"Entry number 3",
@"text2": @"Text 2 by Entry number 3",
@"number": [NSNumber numberWithInt:30],
Expand All @@ -847,6 +850,18 @@ - (void) test_FetchWithPredicates {

NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Entry"];

//// ==
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"check == YES"];
[self assertFetchRequest: fetchRequest block: ^(NSArray *result, NSFetchRequestResultType resultType) {
AssertEq((int)result.count, 2);
}];

//// ==
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"check == NO"];
[self assertFetchRequest: fetchRequest block: ^(NSArray *result, NSFetchRequestResultType resultType) {
AssertEq((int)result.count, 1);
}];

//// ==
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"text == %@", entry1[@"text"]];
[self assertFetchRequest: fetchRequest block: ^(NSArray *result, NSFetchRequestResultType resultType) {
Expand Down Expand Up @@ -1302,6 +1317,11 @@ - (void)test_FetchWithNestedRelationship {
AssertEq((int)result.count, 3);
}];

fetchRequest.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[[NSPredicate predicateWithFormat:@"entry == %@", entry1], [NSPredicate predicateWithFormat:@"number == 10"]]];
[self assertFetchRequest: fetchRequest block: ^(NSArray *result, NSFetchRequestResultType resultType) {
AssertEq((int)result.count, 1);
}];

fetchRequest.predicate = [NSPredicate predicateWithFormat:@"entry.user.name like %@", user1.name];
[self assertFetchRequest: fetchRequest block: ^(NSArray *result, NSFetchRequestResultType resultType) {
AssertEq((int)result.count, 3);
Expand Down

0 comments on commit 6e412fc

Please sign in to comment.