Differences From Artifact [ae3f01c9a0]:
- File
tests/OFDictionary/OFDictionary.m
— part of check-in
[24ecf55297]
at
2009-06-29 12:33:59
on branch trunk
— Changes to OFDictionary, OFIterator and OFList - see details.
OFDictionary:
* More optimized way to internally store the data.
* Faster resizing of dictionaries (no rehashing anymore).OFIterator:
* Return a key/object pair rather than first the key and then the
object.OFList:
* Support for list objects with a different size so you can have your
own list object structs. (user: js, size: 3646) [annotate] [blame] [check-ins using]
To Artifact [8f8688c53b]:
- File tests/OFDictionary/OFDictionary.m — part of check-in [eddc0ba58c] at 2009-06-30 13:38:36 on branch trunk — Implement OFCopying and OFMutableCopying in OFDictionary. (user: js, size: 4471) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
15 16 17 18 19 20 21 | #include <string.h> #import "OFAutoreleasePool.h" #import "OFDictionary.h" #import "OFString.h" #import "OFExceptions.h" | | > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <string.h> #import "OFAutoreleasePool.h" #import "OFDictionary.h" #import "OFString.h" #import "OFExceptions.h" #define TESTS 15 int main() { int i = 0; OFDictionary *dict = [OFMutableDictionary dictionaryWithHashSize: 16]; OFDictionary *dict2; OFIterator *iter = [dict iterator]; of_iterator_pair_t pair[2]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *key1 = [OFString stringWithCString: "key1"]; OFString *key2 = [OFString stringWithCString: "key2"]; OFString *value1 = [OFString stringWithCString: "value1"]; |
︙ | ︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 | } i++; if (![[dict objectForKey: @"k2"] isEqual: @"o2"]) { printf("\033[K\033[1;31mTest %d/%d failed!\033[m\n", i, TESTS); return 1; } printf("\033[1;32mTests successful: %d/%d\033[0m\n", i, TESTS); return 0; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | } i++; if (![[dict objectForKey: @"k2"] isEqual: @"o2"]) { printf("\033[K\033[1;31mTest %d/%d failed!\033[m\n", i, TESTS); return 1; } i++; dict2 = [dict copy]; [dict release]; if (![[dict2 objectForKey: @"k1"] isEqual: @"o1"] || ![[dict2 objectForKey: @"k2"] isEqual: @"o2"]) { printf("\033[K\033[1;31mTest %d/%d failed!\033[m\n", i, TESTS); return 1; } i++; dict = [dict2 mutableCopy]; [dict2 release]; if (![[dict objectForKey: @"k1"] isEqual: @"o1"] || ![[dict objectForKey: @"k2"] isEqual: @"o2"]) { printf("\033[k\033[1;31mtest %d/%d failed!\033[m\n", i, TESTS); return 1; } i++; [dict setObject: @"o0" forKey: @"k1"]; [dict setObject: @"o3" forKey: @"k3"]; if (![[dict objectForKey: @"k1"] isEqual: @"o0"] || ![[dict objectForKey: @"k2"] isEqual: @"o2"] || ![[dict objectForKey: @"k3"] isEqual: @"o3"]) { printf("\033[k\033[1;31mtest %d/%d failed!\033[m\n", i, TESTS); return 1; } printf("\033[1;32mTests successful: %d/%d\033[0m\n", i, TESTS); return 0; } |