UnitTests/TestDictionaryAdditions.m
changeset 5949 334dc418b409
parent 3679 f4294bb53b0f
equal deleted inserted replaced
5893:1e1382dbd844 5949:334dc418b409
    56 
    56 
    57 	[dict translate:translation
    57 	[dict translate:translation
    58 				add:nil
    58 				add:nil
    59 			 remove:nil];
    59 			 remove:nil];
    60 
    60 
    61 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
    61 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
    62 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
    62 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
    63 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
    63 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
    64 }
    64 }
    65 
    65 
    66 - (void)testTranslateAddRemove_add {
    66 - (void)testTranslateAddRemove_add {
    67 	NSMutableDictionary *dict = [self startingDictionary];
    67 	NSMutableDictionary *dict = [self startingDictionary];
    68 
    68 
    69 	[dict translate:nil
    69 	[dict translate:nil
    70 				add:[self addition]
    70 				add:[self addition]
    71 			 remove:nil];
    71 			 remove:nil];
    72 
    72 
    73 	STAssertNotNil([dict objectForKey:@"Foo"],   @"translate:add:remove: method failed to keep %@", @"Foo");
    73 	XCTAssertNotNil([dict objectForKey:@"Foo"],   @"translate:add:remove: method failed to keep %@", @"Foo");
    74 	STAssertNotNil([dict objectForKey:@"Bar"],   @"translate:add:remove: method failed to keep %@", @"Bar");
    74 	XCTAssertNotNil([dict objectForKey:@"Bar"],   @"translate:add:remove: method failed to keep %@", @"Bar");
    75 	STAssertNotNil([dict objectForKey:@"Baz"],   @"translate:add:remove: method failed to keep %@", @"Baz");
    75 	XCTAssertNotNil([dict objectForKey:@"Baz"],   @"translate:add:remove: method failed to keep %@", @"Baz");
    76 	STAssertNotNil([dict objectForKey:@"Qux"],   @"translate:add:remove: method failed to add %@", @"Qux");
    76 	XCTAssertNotNil([dict objectForKey:@"Qux"],   @"translate:add:remove: method failed to add %@", @"Qux");
    77 	STAssertNotNil([dict objectForKey:@"Quux"],  @"translate:add:remove: method failed to add %@", @"Quux");
    77 	XCTAssertNotNil([dict objectForKey:@"Quux"],  @"translate:add:remove: method failed to add %@", @"Quux");
    78 	STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
    78 	XCTAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
    79 }
    79 }
    80 
    80 
    81 - (void)testTranslateAddRemove_remove {
    81 - (void)testTranslateAddRemove_remove {
    82 	NSMutableDictionary *dict = [self startingDictionary];
    82 	NSMutableDictionary *dict = [self startingDictionary];
    83 
    83 
    84 	[dict translate:nil
    84 	[dict translate:nil
    85 				add:nil
    85 				add:nil
    86 			 remove:[self deletia]];
    86 			 remove:[self deletia]];
    87 
    87 
    88 	STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
    88 	XCTAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
    89 	STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
    89 	XCTAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
    90 	STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
    90 	XCTAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
    91 }
    91 }
    92 
    92 
    93 #pragma mark -
    93 #pragma mark -
    94 
    94 
    95 - (void)testTranslateAddRemove_translateAdd {
    95 - (void)testTranslateAddRemove_translateAdd {
    98 
    98 
    99 	[dict translate:translation
    99 	[dict translate:translation
   100 				add:[self addition]
   100 				add:[self addition]
   101 			 remove:nil];
   101 			 remove:nil];
   102 
   102 
   103 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
   103 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
   104 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
   104 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
   105 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
   105 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
   106 
   106 
   107 	STAssertNotNil([dict objectForKey:@"Foo"],   @"translate:add:remove: method failed to keep %@", @"Foo");
   107 	XCTAssertNotNil([dict objectForKey:@"Foo"],   @"translate:add:remove: method failed to keep %@", @"Foo");
   108 	STAssertNotNil([dict objectForKey:@"Bar"],   @"translate:add:remove: method failed to keep %@", @"Bar");
   108 	XCTAssertNotNil([dict objectForKey:@"Bar"],   @"translate:add:remove: method failed to keep %@", @"Bar");
   109 	STAssertNotNil([dict objectForKey:@"Baz"],   @"translate:add:remove: method failed to keep %@", @"Baz");
   109 	XCTAssertNotNil([dict objectForKey:@"Baz"],   @"translate:add:remove: method failed to keep %@", @"Baz");
   110 	STAssertNotNil([dict objectForKey:@"Qux"],   @"translate:add:remove: method failed to add %@", @"Qux");
   110 	XCTAssertNotNil([dict objectForKey:@"Qux"],   @"translate:add:remove: method failed to add %@", @"Qux");
   111 	STAssertNotNil([dict objectForKey:@"Quux"],  @"translate:add:remove: method failed to add %@", @"Quux");
   111 	XCTAssertNotNil([dict objectForKey:@"Quux"],  @"translate:add:remove: method failed to add %@", @"Quux");
   112 	STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
   112 	XCTAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
   113 }
   113 }
   114 
   114 
   115 - (void)testTranslateAddRemove_translateRemove {
   115 - (void)testTranslateAddRemove_translateRemove {
   116 	NSMutableDictionary *dict = [self startingDictionary];
   116 	NSMutableDictionary *dict = [self startingDictionary];
   117 	NSDictionary *translation = [self translation];
   117 	NSDictionary *translation = [self translation];
   118 
   118 
   119 	[dict translate:translation
   119 	[dict translate:translation
   120 				add:nil
   120 				add:nil
   121 			 remove:[self deletia]];
   121 			 remove:[self deletia]];
   122 
   122 
   123 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
   123 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
   124 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
   124 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
   125 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
   125 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
   126 
   126 
   127 	STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
   127 	XCTAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
   128 	STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
   128 	XCTAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
   129 	STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
   129 	XCTAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
   130 }
   130 }
   131 
   131 
   132 - (void)testTranslateAddRemove_addRemove {
   132 - (void)testTranslateAddRemove_addRemove {
   133 	NSMutableDictionary *dict = [self startingDictionary];
   133 	NSMutableDictionary *dict = [self startingDictionary];
   134 
   134 
   135 	[dict translate:nil
   135 	[dict translate:nil
   136 				add:[self addition]
   136 				add:[self addition]
   137 			 remove:[self deletia]];
   137 			 remove:[self deletia]];
   138 
   138 
   139 	STAssertNotNil([dict objectForKey:@"Qux"],   @"translate:add:remove: method failed to add %@", @"Qux");
   139 	XCTAssertNotNil([dict objectForKey:@"Qux"],   @"translate:add:remove: method failed to add %@", @"Qux");
   140 	STAssertNotNil([dict objectForKey:@"Quux"],  @"translate:add:remove: method failed to add %@", @"Quux");
   140 	XCTAssertNotNil([dict objectForKey:@"Quux"],  @"translate:add:remove: method failed to add %@", @"Quux");
   141 	STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
   141 	XCTAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
   142 
   142 
   143 	STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
   143 	XCTAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
   144 	STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
   144 	XCTAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
   145 	STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
   145 	XCTAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
   146 }
   146 }
   147 
   147 
   148 #pragma mark -
   148 #pragma mark -
   149 
   149 
   150 - (void)testTranslateAddRemove_translateAddRemove {
   150 - (void)testTranslateAddRemove_translateAddRemove {
   153 
   153 
   154 	[dict translate:translation
   154 	[dict translate:translation
   155 				add:[self addition]
   155 				add:[self addition]
   156 			 remove:[self deletia]];
   156 			 remove:[self deletia]];
   157 
   157 
   158 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
   158 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Foo"]], @"translate:add:remove: method failed to translate %@ to %@", @"Foo", [translation objectForKey:@"Foo"]);
   159 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
   159 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Bar"]], @"translate:add:remove: method failed to translate %@ to %@", @"Bar", [translation objectForKey:@"Bar"]);
   160 	STAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
   160 	XCTAssertNotNil([dict objectForKey:[translation objectForKey:@"Baz"]], @"translate:add:remove: method failed to translate %@ to %@", @"Baz", [translation objectForKey:@"Baz"]);
   161 
   161 
   162 	STAssertNotNil([dict objectForKey:@"Qux"],   @"translate:add:remove: method failed to add %@", @"Qux");
   162 	XCTAssertNotNil([dict objectForKey:@"Qux"],   @"translate:add:remove: method failed to add %@", @"Qux");
   163 	STAssertNotNil([dict objectForKey:@"Quux"],  @"translate:add:remove: method failed to add %@", @"Quux");
   163 	XCTAssertNotNil([dict objectForKey:@"Quux"],  @"translate:add:remove: method failed to add %@", @"Quux");
   164 	STAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
   164 	XCTAssertNotNil([dict objectForKey:@"Quuux"], @"translate:add:remove: method failed to add %@", @"Quuux");
   165 
   165 
   166 	STAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
   166 	XCTAssertNil([dict objectForKey:@"Foo"], @"translate:add:remove: method failed to remove %@", @"Foo");
   167 	STAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
   167 	XCTAssertNil([dict objectForKey:@"Bar"], @"translate:add:remove: method failed to remove %@", @"Bar");
   168 	STAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
   168 	XCTAssertNil([dict objectForKey:@"Baz"], @"translate:add:remove: method failed to remove %@", @"Baz");
   169 }
   169 }
   170 
   170 
   171 @end
   171 @end