11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#import "config.h"
#include <stdio.h>
#include <string.h>
#import "OFString.h"
#import "OFExceptions.h"
#import "OFAutoreleasePool.h"
#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif
#define NUM_TESTS 15
#define SUCCESS \
printf("\r\033[1;%dmTests successful: " ZD "/%d\033[0m", \
(i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS); \
fflush(stdout);
#define FAIL \
printf("\r\033[K\033[1;31mTest " ZD "/%d failed!\033[m\n", \
i + 1, NUM_TESTS); \
|
>
|
>
|
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#import "config.h"
#include <stdio.h>
#include <string.h>
#import "OFString.h"
#import "OFConstString.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif
#define NUM_TESTS 21
#define SUCCESS \
printf("\r\033[1;%dmTests successful: " ZD "/%d\033[0m", \
(i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS); \
fflush(stdout);
#define FAIL \
printf("\r\033[K\033[1;31mTest " ZD "/%d failed!\033[m\n", \
i + 1, NUM_TESTS); \
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
} \
i++;
int
main()
{
size_t i = 0;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *s1 = [OFString stringWithCString: "test"];
OFString *s2 = [OFString stringWithCString: ""];
OFString *s3;
OFString *s4 = [OFString string];
s3 = [s1 copy];
CHECK([s1 isEqual: s3])
CHECK(![s1 isEqual: [[OFObject alloc] init]])
CHECK([s1 hash] == [s3 hash])
|
>
>
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
} \
i++;
int
main()
{
size_t i = 0;
size_t j = 0;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *s1 = [OFString stringWithCString: "test"];
OFString *s2 = [OFString stringWithCString: ""];
OFString *s3;
OFString *s4 = [OFString string];
OFArray *a;
s3 = [s1 copy];
CHECK([s1 isEqual: s3])
CHECK(![s1 isEqual: [[OFObject alloc] init]])
CHECK([s1 hash] == [s3 hash])
|
92
93
94
95
96
97
98
99
100
101
102
103
|
/* Format tests */
s1 = [OFString stringWithFormat: "%s: %d", "test", 123];
CHECK(!strcmp([s1 cString], "test: 123"))
[s1 appendWithFormatCString: "%02X", 15];
CHECK(!strcmp([s1 cString], "test: 1230F"))
puts("");
return 0;
}
|
>
>
>
>
>
>
>
>
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/* Format tests */
s1 = [OFString stringWithFormat: "%s: %d", "test", 123];
CHECK(!strcmp([s1 cString], "test: 123"))
[s1 appendWithFormatCString: "%02X", 15];
CHECK(!strcmp([s1 cString], "test: 1230F"))
a = [@"fooXXbarXXXXbazXXXX" splitWithDelimiter: @"XX"];
CHECK([[a object: j++] isEqual: @"foo"])
CHECK([[a object: j++] isEqual: @"bar"])
CHECK([[a object: j++] isEqual: @""])
CHECK([[a object: j++] isEqual: @"baz"])
CHECK([[a object: j++] isEqual: @""])
CHECK([[a object: j++] isEqual: @""])
puts("");
return 0;
}
|