Differences From Artifact [76bc88ef2a]:
- File tests/OFDictionaryTests.m — part of check-in [2fafde4058] at 2017-06-25 17:13:29 on branch trunk — Add -[OFDictionary stringByURLEncoding] (user: js, size: 9997) [annotate] [blame] [check-ins using] [more...]
To Artifact [ed8d42f32f]:
- File
tests/OFDictionaryTests.m
— part of check-in
[7e29a62cc6]
at
2017-10-14 18:52:37
on branch trunk
— Fix more shadowed variables
Clang didn't complain about these, but GCC did. (user: js, size: 10049) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
78 79 80 81 82 83 84 | @throw e; } return self; } - initWithObjects: (const id *)objects | | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | @throw e; } return self; } - initWithObjects: (const id *)objects forKeys: (const id *)keys_ count: (size_t)count { self = [super init]; @try { _dictionary = [[OFMutableDictionary alloc] initWithObjects: objects forKeys: keys_ count: count]; } @catch (id e) { [self release]; @throw e; } return self; |
︙ | ︙ | |||
264 265 266 267 268 269 270 | TEST(@"-[stringByURLEncoding]", [[[OFDictionary dictionaryWithKeysAndObjects: @"foo", @"bar", @"q&x", @"q=x", nil] stringByURLEncoding] isEqual: @"q%26x=q%3Dx&foo=bar"]) #ifdef OF_HAVE_BLOCKS { | | | | | | | | | | | | | | | > | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | TEST(@"-[stringByURLEncoding]", [[[OFDictionary dictionaryWithKeysAndObjects: @"foo", @"bar", @"q&x", @"q=x", nil] stringByURLEncoding] isEqual: @"q%26x=q%3Dx&foo=bar"]) #ifdef OF_HAVE_BLOCKS { __block size_t j = 0; __block bool blockOk = true; [mutDict enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, bool *stop) { if (j > 1 || ![key isEqual: keys[j]]) { blockOk = false; *stop = true; return; } [mutDict setObject: [mutDict objectForKey: key] forKey: key]; j++; }]; TEST(@"Enumeration using blocks", blockOk) blockOk = false; @try { [mutDict enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, bool *stop) { [mutDict setObject: @"" forKey: @""]; }]; } @catch (OFEnumerationMutationException *e) { blockOk = true; } TEST(@"Detection of mutation during enumeration using blocks", blockOk) [mutDict removeObjectForKey: @""]; } TEST(@"-[replaceObjectsUsingBlock:]", R([mutDict replaceObjectsUsingBlock: ^ id (id key, id object) { if ([key isEqual: keys[0]]) return @"value_1"; if ([key isEqual: keys[1]]) return @"value_2"; return nil; }]) && [[mutDict objectForKey: keys[0]] isEqual: @"value_1"] && [[mutDict objectForKey: keys[1]] isEqual: @"value_2"]) TEST(@"-[mappedDictionaryUsingBlock:]", [[[mutDict mappedDictionaryUsingBlock: ^ id (id key, id object) { if ([key isEqual: keys[0]]) return @"val1"; if ([key isEqual: keys[1]]) return @"val2"; return nil; }] description] isEqual: @"{\n\tkey1 = val1;\n\tkey2 = val2;\n}"]) TEST(@"-[filteredDictionaryUsingBlock:]", [[[mutDict filteredDictionaryUsingBlock: ^ bool (id key, id object) { return [key isEqual: keys[0]]; }] description] isEqual: @"{\n\tkey1 = value_1;\n}"]) #endif TEST(@"-[count]", [mutDict count] == 2) TEST(@"+[dictionaryWithKeysAndObjects:]", |
︙ | ︙ |