Differences From Artifact [04d0bf130a]:
- File
tests/OFDictionaryTests.m
— part of check-in
[e1e7ffa903]
at
2011-09-22 23:25:42
on branch trunk
— Exceptions are now autoreleased.
This is safe as an "exception loop" can't happen, since if allocating
an exception fails, it throws an OFAllocFailedException which is
preallocated and can always be thrown.So, the worst case would be that an autorelease of an exception fails,
triggering an OFOutOfMemoryException for which there is no memory,
resulting in an OFAllocFailedException to be thrown. (user: js, size: 6791) [annotate] [blame] [check-ins using]
To Artifact [3c41c1f125]:
- File tests/OFDictionaryTests.m — part of check-in [d8a6ca3fbd] at 2011-11-21 16:47:00 on branch trunk — There is no need to hash 32 bit per character if Unicode has only 24. (user: js, size: 6871) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
94 95 96 97 98 99 100 | forKey: keys[0]]; #ifdef OF_HAVE_FAST_ENUMERATION size_t i = 0; BOOL ok = YES; for (OFString *key in dict) { | | > > > | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | forKey: keys[0]]; #ifdef OF_HAVE_FAST_ENUMERATION size_t i = 0; BOOL ok = YES; for (OFString *key in dict) { if (i > 1 || ![key isEqual: keys[1 - i]]) { ok = NO; break; } [dict setObject: [dict objectForKey: key] forKey: key]; i++; } TEST(@"Fast Enumeration", ok) |
︙ | ︙ | |||
124 125 126 127 128 129 130 | #ifdef OF_HAVE_BLOCKS { __block size_t i = 0; __block BOOL ok = YES; [dict enumerateKeysAndObjectsUsingBlock: ^ (id key, id obj, BOOL *stop) { | | > > > > | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | #ifdef OF_HAVE_BLOCKS { __block size_t i = 0; __block BOOL ok = YES; [dict enumerateKeysAndObjectsUsingBlock: ^ (id key, id obj, BOOL *stop) { if (i > 1 || ![key isEqual: keys[1 - i]]) { ok = NO; *stop = YES; return; } [dict setObject: [dict objectForKey: key] forKey: key]; i++; }]; TEST(@"Enumeration using blocks", ok) |
︙ | ︙ | |||
170 171 172 173 174 175 176 | [[[dict mappedDictionaryUsingBlock: ^ id (id key, id obj) { if ([key isEqual: keys[0]]) return @"val1"; if ([key isEqual: keys[1]]) return @"val2"; return nil; | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | [[[dict mappedDictionaryUsingBlock: ^ id (id key, id obj) { if ([key isEqual: keys[0]]) return @"val1"; if ([key isEqual: keys[1]]) return @"val2"; return nil; }] description] isEqual: @"{\n\tkey2 = val2;\n\tkey1 = val1;\n}"]) TEST(@"-[filteredDictionaryUsingBlock:]", [[[dict filteredDictionaryUsingBlock: ^ BOOL (id key, id obj) { return ([key isEqual: keys[0]] ? YES : NO); }] description] isEqual: @"{\n\tkey1 = value_1;\n}"]) #endif |
︙ | ︙ |