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
|
#import <stdlib.h>
#import <string.h>
#import <wchar.h>
#import "OFXMLFactory.h"
inline void
check_result(char *result, const char *should)
{
/* Use wprintf here so we don't mix printf and wprintf! */
if (!strcmp(result, should))
wprintf(L"%s is expected result\n", result);
else {
wprintf(L"%s is NOT expected result!\n", result);
exit(1);
}
free(result);
}
inline void
check_result_wide(wchar_t *result, const wchar_t *should)
{
if (!wcscmp(result, should))
wprintf(L"%ls is expected result\n", result);
else {
wprintf(L"%ls is NOT expected result!\n", result);
exit(1);
}
free(result);
}
inline void
|
>
>
>
>
>
|
|
>
>
|
>
>
>
>
|
|
>
>
|
>
>
|
|
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
|
#import <stdlib.h>
#import <string.h>
#import <wchar.h>
#import "OFXMLFactory.h"
#define NUM_TESTS 10
static int i;
inline void
check_result(char *result, const char *should)
{
/* Use wprintf here so we don't mix printf and wprintf! */
i++;
if (!strcmp(result, should)) {
wprintf(L"\r\033[1;%dmchar* tests successful: %2d/%d\033[0m",
(i == NUM_TESTS ? 32 : 33), i, NUM_TESTS);
fflush(stdout);
} else {
wprintf(L"\r\033[1;31mchar* test %d/%d failed!\033[0m\n",
i, NUM_TESTS);
wprintf(L"%s is NOT expected result!\n", result);
exit(1);
}
free(result);
}
inline void
check_result_wide(wchar_t *result, const wchar_t *should)
{
i++;
if (!wcscmp(result, should)) {
wprintf(L"\r\033[1;%dmwchar_t* tests successful: %2d/%d\033[0m",
(i == NUM_TESTS ? 32 : 33), i, NUM_TESTS);
fflush(stdout);
} else {
wprintf(L"\r\033[1;31mwchar_t* test %d/%d failed!\033[0m\n",
i, NUM_TESTS);
wprintf(L"%s is NOT expected result!\n", result);
exit(1);
}
free(result);
}
inline void
|
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
[OFXMLFactory escapeWideCString: L"<hallo> &welt'\"!&"],
L"<hallo> &welt'"!&");
}
int main()
{
test_escape();
test_create_stanza();
test_concat();
wprintf(L"== Now testing with wide C strings ==\n");
test_escape_wide();
test_create_stanza_wide();
test_concat_wide();
return 0;
}
|
>
<
|
>
>
|
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
[OFXMLFactory escapeWideCString: L"<hallo> &welt'\"!&"],
L"<hallo> &welt'"!&");
}
int main()
{
i = 0;
test_escape();
test_create_stanza();
test_concat();
wprintf(L"\n");
i = 0;
test_escape_wide();
test_create_stanza_wide();
test_concat_wide();
wprintf(L"\n");
return 0;
}
|