14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include <stdio.h>
#include <string.h>
#import "OFAutoreleasePool.h"
#import "OFDictionary.h"
#import "OFConstString.h"
#import "OFString.h"
int
main()
{
OFDictionary *dict = [OFDictionary dictionaryWithHashSize: 16];
OFAutoreleasePool *pool = [OFAutoreleasePool new];
OFString *key1 = [OFString stringWithCString: "key1"];
OFString *key2 = [OFString stringWithCString: "key2"];
OFString *value1 = [OFString stringWithCString: "value1"];
OFString *value2 = [OFString stringWithCString: "value2"];
[dict set: key1
to: value1];
[dict set: key2
to: value2];
[pool release];
if (strcmp([[dict get: @"key1"] cString], "value1")) {
puts("\033[K\033[1;31mTest 1/2 failed!\033[m");
return 1;
}
if (strcmp([[dict get: key2] cString], "value2")) {
puts("\033[K\033[1;31mTest 2/2 failed!\033[m");
return 1;
}
puts("\033[1;32mTests successful: 2/2\033[0m");
return 0;
}
|
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#include <stdio.h>
#include <string.h>
#import "OFAutoreleasePool.h"
#import "OFDictionary.h"
#import "OFConstString.h"
#import "OFString.h"
#import "OFExceptions.h"
int
main()
{
BOOL caught;
OFDictionary *dict = [OFDictionary dictionaryWithHashSize: 16];
OFAutoreleasePool *pool = [OFAutoreleasePool new];
OFString *key1 = [OFString stringWithCString: "key1"];
OFString *key2 = [OFString stringWithCString: "key2"];
OFString *value1 = [OFString stringWithCString: "value1"];
OFString *value2 = [OFString stringWithCString: "value2"];
[dict set: key1
to: value1];
[dict set: key2
to: value2];
[pool release];
if (strcmp([[dict get: @"key1"] cString], "value1")) {
puts("\033[K\033[1;31mTest 1/4 failed!\033[m");
return 1;
}
if (strcmp([[dict get: key2] cString], "value2")) {
puts("\033[K\033[1;31mTest 2/4 failed!\033[m");
return 1;
}
caught = NO;
@try {
[dict get: @"key3"];
} @catch (OFNotInSetException *e) {
caught = YES;
}
if (!caught) {
puts("\033[K\033[1;31mTest 3/4 failed!\033[m");
return 1;
}
[dict remove: @"key2"];
caught = NO;
@try {
[dict remove: @"key2"];
} @catch (OFNotInSetException *e) {
caught = YES;
}
if (!caught) {
puts("\033[K\033[1;31mTest 4/4 failed!\033[m");
return 1;
}
puts("\033[1;32mTests successful: 4/4\033[0m");
return 0;
}
|