William Bowling is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this again1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | #import "TestDictionaryAdditions.h"
#import <AIUtilities/AIDictionaryAdditions.h>
@implementation TestDictionaryAdditions
- (NSMutableDictionary *)startingDictionary {
return [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedInteger:0U], @"Foo",
[NSNumber numberWithUnsignedInteger:1U], @"Bar",
[NSNumber numberWithUnsignedInteger:2U], @"Baz",
nil];
}
- (NSDictionary *)translation {
return [NSDictionary dictionaryWithObjectsAndKeys:
@"Green", @"Foo",
@"Red", @"Bar",
@"Blue", @"Baz",
nil];
}
- (NSDictionary *)addition {
return [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedInteger:3U], @"Qux",
[NSNumber numberWithUnsignedInteger:4U], @"Quux",
[NSNumber numberWithUnsignedInteger:5U], @"Quuux",
nil];
}
- (NSSet *)deletia {
return [NSSet setWithObjects:
@"Foo",
@"Bar",
@"Baz",
nil];
}
#pragma mark Test case methods
- (void)testTranslateAddRemove_translate {
NSMutableDictionary *dict = [self startingDictionary];
NSDictionary *translation = [self translation];
[dict translate:translation
add:nil
remove:nil];
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
}
- (void)testTranslateAddRemove_add {
NSMutableDictionary *dict = [self startingDictionary];
[dict translate:nil
add:[self addition]
remove:nil];
STAssertNotNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to keep %@", @"Foo");
STAssertNotNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to keep %@", @"Bar");
STAssertNotNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to keep %@", @"Baz");
STAssertNotNil([dict objectForKey:@"Qux"], @"translate:add:remove: method failed to add %@", @"Qux");
STAssertNotNil([dict objectForKey:@"Quux"], @"translate:add:remove: method failed to add %@", @"Quux");
STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
}
- (void)testTranslateAddRemove_remove {
NSMutableDictionary *dict = [self startingDictionary];
[dict translate:nil
add:nil
remove:[self deletia]];
STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
}
#pragma mark -
- (void)testTranslateAddRemove_translateAdd {
NSMutableDictionary *dict = [self startingDictionary];
NSDictionary *translation = [self translation];
[dict translate:translation
add:[self addition]
remove:nil];
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
STAssertNotNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to keep %@", @"Foo");
STAssertNotNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to keep %@", @"Bar");
STAssertNotNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to keep %@", @"Baz");
STAssertNotNil([dict objectForKey:@"Qux"], @"translate:add:remove: method failed to add %@", @"Qux");
STAssertNotNil([dict objectForKey:@"Quux"], @"translate:add:remove: method failed to add %@", @"Quux");
STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
}
- (void)testTranslateAddRemove_translateRemove {
NSMutableDictionary *dict = [self startingDictionary];
NSDictionary *translation = [self translation];
[dict translate:translation
add:nil
remove:[self deletia]];
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
}
- (void)testTranslateAddRemove_addRemove {
NSMutableDictionary *dict = [self startingDictionary];
[dict translate:nil
add:[self addition]
remove:[self deletia]];
STAssertNotNil([dict objectForKey:@"Qux"], @"translate:add:remove: method failed to add %@", @"Qux");
STAssertNotNil([dict objectForKey:@"Quux"], @"translate:add:remove: method failed to add %@", @"Quux");
STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
}
#pragma mark -
- (void)testTranslateAddRemove_translateAddRemove {
NSMutableDictionary *dict = [self startingDictionary];
NSDictionary *translation = [self translation];
[dict translate:translation
add:[self addition]
remove:[self deletia]];
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
STAssertNotNil([dict objectForKey:@"Qux"], @"translate:add:remove: method failed to add %@", @"Qux");
STAssertNotNil([dict objectForKey:@"Quux"], @"translate:add:remove: method failed to add %@", @"Quux");
STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
}
@end
|