21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif
#define NUM_TESTS 39
#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); \
|
|
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif
#define NUM_TESTS 47
#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); \
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/* Format tests */
s1 = [OFMutableString stringWithFormat: @"%s: %d", "test", 123];
CHECK(!strcmp([s1 cString], "test: 123"))
[s1 appendWithFormat: @"%02X", 15];
CHECK(!strcmp([s1 cString], "test: 1230F"))
/* Substring tests */
CHECK([[@"foo" substringFromIndex: 1
toIndex: 2] isEqual: @"o"]);
CHECK([[@"foo" substringFromIndex: 3
toIndex: 3] isEqual: @""]);
CHECK_EXCEPT([@"foo" substringFromIndex: 2
toIndex: 4], OFOutOfRangeException)
|
>
>
>
>
>
>
>
>
>
>
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/* Format tests */
s1 = [OFMutableString stringWithFormat: @"%s: %d", "test", 123];
CHECK(!strcmp([s1 cString], "test: 123"))
[s1 appendWithFormat: @"%02X", 15];
CHECK(!strcmp([s1 cString], "test: 1230F"))
/* Find index tests */
CHECK([@"foo" indexOfFirstOccurrenceOfString: @"oo"] == 1)
CHECK([@"foo" indexOfLastOccurrenceOfString: @"oo"] == 1)
CHECK([@"foo" indexOfFirstOccurrenceOfString: @"o"] == 1)
CHECK([@"foo" indexOfLastOccurrenceOfString: @"o"] == 2)
CHECK([@"foo" indexOfFirstOccurrenceOfString: @"f"] == 0)
CHECK([@"foo" indexOfLastOccurrenceOfString: @"f"] == 0)
CHECK([@"foo" indexOfFirstOccurrenceOfString: @"x"] == SIZE_MAX)
CHECK([@"foo" indexOfLastOccurrenceOfString: @"x"] == SIZE_MAX)
/* Substring tests */
CHECK([[@"foo" substringFromIndex: 1
toIndex: 2] isEqual: @"o"]);
CHECK([[@"foo" substringFromIndex: 3
toIndex: 3] isEqual: @""]);
CHECK_EXCEPT([@"foo" substringFromIndex: 2
toIndex: 4], OFOutOfRangeException)
|