20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif
#define NUM_TESTS 70
#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); \
|
|
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif
#define NUM_TESTS 71
#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); \
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
CHECK_EXCEPT(s1 = [OFString stringWithCString: "\xF0\x80\x80\xC0"],
OFInvalidEncodingException)
s1 = [OFMutableString stringWithCString: "äöü€𝄞"];
CHECK([[s1 reverse] isEqual: @"𝄞€üöä"])
[s1 dealloc];
/* ISO-8859-1 tests */
CHECK([[OFString stringWithCString: "\xE4\xF6\xFC"
encoding: OF_STRING_ENCODING_ISO_8859_1]
isEqual: @"äöü"])
CHECK([[OFString stringWithCString: "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE"
encoding: OF_STRING_ENCODING_ISO_8859_15]
isEqual: @"€ŠšŽžŒœŸ"])
/* Format tests */
s1 = [OFMutableString stringWithFormat: @"%s: %d", "test", 123];
CHECK([s1 isEqual: @"test: 123"])
[s1 appendWithFormat: @"%02X", 15];
CHECK([s1 isEqual: @"test: 1230F"])
|
|
>
>
>
>
>
>
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
CHECK_EXCEPT(s1 = [OFString stringWithCString: "\xF0\x80\x80\xC0"],
OFInvalidEncodingException)
s1 = [OFMutableString stringWithCString: "äöü€𝄞"];
CHECK([[s1 reverse] isEqual: @"𝄞€üöä"])
[s1 dealloc];
/* Encoding tests */
CHECK([[OFString stringWithCString: "\xE4\xF6\xFC"
encoding: OF_STRING_ENCODING_ISO_8859_1]
isEqual: @"äöü"])
CHECK([[OFString stringWithCString: "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE"
encoding: OF_STRING_ENCODING_ISO_8859_15]
isEqual: @"€ŠšŽžŒœŸ"])
CHECK([[OFString stringWithCString: "\x80\x82\x83\x84\x85\x86\x87\x88"
"\x89\x8A\x8B\x8C\x8E\x91\x92\x93"
"\x94\x95\x96\x97\x98\x99\x9A\x9B"
"\x9C\x9E\x9F"
encoding: OF_STRING_ENCODING_WINDOWS_1252]
isEqual: @"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ"])
/* Format tests */
s1 = [OFMutableString stringWithFormat: @"%s: %d", "test", 123];
CHECK([s1 isEqual: @"test: 123"])
[s1 appendWithFormat: @"%02X", 15];
CHECK([s1 isEqual: @"test: 1230F"])
|