1 #import "TestDictionaryAdditions.h"
3 #import <AIUtilities/AIDictionaryAdditions.h>
5 @implementation TestDictionaryAdditions
7 - (NSMutableDictionary *)startingDictionary {
8 return [NSMutableDictionary dictionaryWithObjectsAndKeys:
9 [NSNumber numberWithUnsignedInt:0U], @"Foo",
10 [NSNumber numberWithUnsignedInt:1U], @"Bar",
11 [NSNumber numberWithUnsignedInt:2U], @"Baz",
14 - (NSDictionary *)translation {
15 return [NSDictionary dictionaryWithObjectsAndKeys:
21 - (NSDictionary *)addition {
22 return [NSDictionary dictionaryWithObjectsAndKeys:
23 [NSNumber numberWithUnsignedInt:3U], @"Qux",
24 [NSNumber numberWithUnsignedInt:4U], @"Quux",
25 [NSNumber numberWithUnsignedInt:5U], @"Quuux",
29 return [NSSet setWithObjects:
36 #pragma mark Test case methods
38 - (void)testTranslateAddRemove_translate {
39 NSMutableDictionary *dict = [self startingDictionary];
40 NSDictionary *translation = [self translation];
42 [dict translate:translation
46 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
47 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
48 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
51 - (void)testTranslateAddRemove_add {
52 NSMutableDictionary *dict = [self startingDictionary];
58 STAssertNotNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to keep %@", @"Foo");
59 STAssertNotNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to keep %@", @"Bar");
60 STAssertNotNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to keep %@", @"Baz");
61 STAssertNotNil([dict objectForKey:@"Qux"], @"translate:add:remove: method failed to add %@", @"Qux");
62 STAssertNotNil([dict objectForKey:@"Quux"], @"translate:add:remove: method failed to add %@", @"Quux");
63 STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
66 - (void)testTranslateAddRemove_remove {
67 NSMutableDictionary *dict = [self startingDictionary];
71 remove:[self deletia]];
73 STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
74 STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
75 STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
80 - (void)testTranslateAddRemove_translateAdd {
81 NSMutableDictionary *dict = [self startingDictionary];
82 NSDictionary *translation = [self translation];
84 [dict translate:translation
88 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
89 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
90 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
92 STAssertNotNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to keep %@", @"Foo");
93 STAssertNotNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to keep %@", @"Bar");
94 STAssertNotNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to keep %@", @"Baz");
95 STAssertNotNil([dict objectForKey:@"Qux"], @"translate:add:remove: method failed to add %@", @"Qux");
96 STAssertNotNil([dict objectForKey:@"Quux"], @"translate:add:remove: method failed to add %@", @"Quux");
97 STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
100 - (void)testTranslateAddRemove_translateRemove {
101 NSMutableDictionary *dict = [self startingDictionary];
102 NSDictionary *translation = [self translation];
104 [dict translate:translation
106 remove:[self deletia]];
108 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
109 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
110 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
112 STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
113 STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
114 STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
117 - (void)testTranslateAddRemove_addRemove {
118 NSMutableDictionary *dict = [self startingDictionary];
122 remove:[self deletia]];
124 STAssertNotNil([dict objectForKey:@"Qux"], @"translate:add:remove: method failed to add %@", @"Qux");
125 STAssertNotNil([dict objectForKey:@"Quux"], @"translate:add:remove: method failed to add %@", @"Quux");
126 STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
128 STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
129 STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
130 STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
135 - (void)testTranslateAddRemove_translateAddRemove {
136 NSMutableDictionary *dict = [self startingDictionary];
137 NSDictionary *translation = [self translation];
139 [dict translate:translation
141 remove:[self deletia]];
143 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
144 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
145 STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
147 STAssertNotNil([dict objectForKey:@"Qux"], @"translate:add:remove: method failed to add %@", @"Qux");
148 STAssertNotNil([dict objectForKey:@"Quux"], @"translate:add:remove: method failed to add %@", @"Quux");
149 STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
151 STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
152 STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
153 STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");