2 * Copyright 2011, Oliver Tappe, zooey@hirschkaefer.de
3 * Distributed under the terms of the MIT License.
7 // for wmempcpy() and wcschrnul()
18 static int sign (int a
)
28 // #pragma mark - wcslen -------------------------------------------------------
34 printf("wcslen()/wcsnlen()\n");
40 const wchar_t* string
= L
"";
41 size_t result
= wcslen(string
);
43 if (result
!= expected
|| errno
!= 0) {
44 printf("\tPROBLEM: result for wcslen(\"%ls\") = %lu (expected %lu),"
45 " errno = %x (expected %x)\n", string
, result
, expected
,
52 const wchar_t* string
= L
"test";
53 size_t result
= wcslen(string
);
55 if (result
!= expected
|| errno
!= 0) {
56 printf("\tPROBLEM: result for wcslen(\"%ls\") = %lu (expected %lu),"
57 " errno = %x (expected %x)\n", string
, result
, expected
,
64 const wchar_t* string
= L
"t\xE4st";
65 size_t result
= wcslen(string
);
67 if (result
!= expected
|| errno
!= 0) {
68 printf("\tPROBLEM: result for wcslen(\"%ls\") = %lu (expected %lu),"
69 " errno = %x (expected %x)\n", string
, result
, expected
,
76 const wchar_t* string
= L
"te\x00st";
77 size_t result
= wcslen(string
);
79 if (result
!= expected
|| errno
!= 0) {
80 printf("\tPROBLEM: result for wcslen(\"%ls\") = %lu (expected %lu),"
81 " errno = %x (expected %x)\n", string
, result
, expected
,
88 const wchar_t* string
= L
"test";
89 size_t result
= wcsnlen(string
, 0);
91 if (result
!= expected
|| errno
!= 0) {
92 printf("\tPROBLEM: result for wcsnlen(\"%ls\", 0) = %lu "
93 "(expected %lu), errno = %x (expected %x)\n",
94 string
, result
, expected
, errno
, 0);
100 const wchar_t* string
= L
"test";
101 size_t result
= wcsnlen(string
, 4);
103 if (result
!= expected
|| errno
!= 0) {
104 printf("\tPROBLEM: result for wcsnlen(\"%ls\", 4) = %lu "
105 "(expected %lu), errno = %x (expected %x)\n",
106 string
, result
, expected
, errno
, 0);
112 const wchar_t* string
= L
"test";
113 size_t result
= wcsnlen(string
, 6);
115 if (result
!= expected
|| errno
!= 0) {
116 printf("\tPROBLEM: result for wcsnlen(\"%ls\", 6) = %lu "
117 "(expected %lu), errno = %x (expected %x)\n",
118 string
, result
, expected
, errno
, 0);
124 printf("\t%d problem(s) found!\n", problemCount
);
126 printf("\tall fine\n");
130 // #pragma mark - wcscmp -------------------------------------------------------
136 printf("wcscmp()/wcsncmp()\n");
138 int problemCount
= 0;
142 const wchar_t* a
= L
"";
143 const wchar_t* b
= L
"";
144 int result
= sign(wcscmp(a
, b
));
146 if (result
!= expected
|| errno
!= 0) {
147 printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") = %d "
148 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
155 const wchar_t* a
= L
"a";
156 const wchar_t* b
= L
"b";
157 int result
= sign(wcscmp(a
, b
));
159 if (result
!= expected
|| errno
!= 0) {
160 printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") = %d "
161 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
168 const wchar_t* a
= L
"b";
169 const wchar_t* b
= L
"a";
170 int result
= sign(wcscmp(a
, b
));
172 if (result
!= expected
|| errno
!= 0) {
173 printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") = %d "
174 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
181 const wchar_t* a
= L
"a";
182 const wchar_t* b
= L
"A";
183 int result
= sign(wcscmp(a
, b
));
185 if (result
!= expected
|| errno
!= 0) {
186 printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") = %d "
187 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
194 const wchar_t* a
= L
"täst";
195 const wchar_t* b
= L
"täst";
196 int result
= sign(wcscmp(a
, b
));
198 if (result
!= expected
|| errno
!= 0) {
199 printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") = %d "
200 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
207 const wchar_t* a
= L
"täst";
208 const wchar_t* b
= L
"täst ";
209 int result
= sign(wcscmp(a
, b
));
211 if (result
!= expected
|| errno
!= 0) {
212 printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") = %d "
213 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
220 const wchar_t* a
= L
"täSt";
221 const wchar_t* b
= L
"täs";
222 int result
= sign(wcscmp(a
, b
));
224 if (result
!= expected
|| errno
!= 0) {
225 printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") = %d "
226 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
233 const wchar_t* a
= L
"täst1";
234 const wchar_t* b
= L
"täst0";
235 int result
= sign(wcsncmp(a
, b
, 0));
237 if (result
!= expected
|| errno
!= 0) {
238 printf("\tPROBLEM: result for wcsncmp(\"%ls\", \"%ls\", 0) = %d "
239 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
246 const wchar_t* a
= L
"täst1";
247 const wchar_t* b
= L
"täst0";
248 int result
= sign(wcsncmp(a
, b
, 4));
250 if (result
!= expected
|| errno
!= 0) {
251 printf("\tPROBLEM: result for wcsncmp(\"%ls\", \"%ls\", 4) = %d "
252 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
259 const wchar_t* a
= L
"täst1";
260 const wchar_t* b
= L
"täst0";
261 int result
= sign(wcsncmp(a
, b
, 5));
263 if (result
!= expected
|| errno
!= 0) {
264 printf("\tPROBLEM: result for wcsncmp(\"%ls\", \"%ls\", 5) = %d "
265 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
272 const wchar_t* a
= L
"täs";
273 const wchar_t* b
= L
"täst123";
274 int result
= sign(wcsncmp(a
, b
, (size_t)-1));
276 if (result
!= expected
|| errno
!= 0) {
277 printf("\tPROBLEM: result for wcsncmp(\"%ls\", \"%ls\", -1) = %d "
278 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
285 printf("\t%d problem(s) found!\n", problemCount
);
287 printf("\tall fine\n");
291 // #pragma mark - wcscasecmp ---------------------------------------------------
297 printf("wcscasecmp()/wcsncasecmp()\n");
299 int problemCount
= 0;
303 const wchar_t* a
= L
"";
304 const wchar_t* b
= L
"";
305 int result
= sign(wcscasecmp(a
, b
));
307 if (result
!= expected
|| errno
!= 0) {
308 printf("\tPROBLEM: result for wcscasecmp(\"%ls\", \"%ls\") = %d "
309 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
316 const wchar_t* a
= L
"a";
317 const wchar_t* b
= L
"b";
318 int result
= sign(wcscasecmp(a
, b
));
320 if (result
!= expected
|| errno
!= 0) {
321 printf("\tPROBLEM: result for wcscasecmp(\"%ls\", \"%ls\") = %d "
322 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
329 const wchar_t* a
= L
"B";
330 const wchar_t* b
= L
"a";
331 int result
= sign(wcscasecmp(a
, b
));
333 if (result
!= expected
|| errno
!= 0) {
334 printf("\tPROBLEM: result for wcscasecmp(\"%ls\", \"%ls\") = %d "
335 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
342 const wchar_t* a
= L
"a";
343 const wchar_t* b
= L
"A";
344 int result
= sign(wcscasecmp(a
, b
));
346 if (result
!= expected
|| errno
!= 0) {
347 printf("\tPROBLEM: result for wcscasecmp(\"%ls\", \"%ls\") = %d "
348 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
355 const wchar_t* a
= L
"TÄST";
356 const wchar_t* b
= L
"täst";
357 int result
= sign(wcscasecmp(a
, b
));
359 if (result
!= expected
|| errno
!= 0) {
360 printf("\tPROBLEM: result for wcscasecmp(\"%ls\", \"%ls\") = %d "
361 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
368 const wchar_t* a
= L
"tÄst";
369 const wchar_t* b
= L
"täst ";
370 int result
= sign(wcscasecmp(a
, b
));
372 if (result
!= expected
|| errno
!= 0) {
373 printf("\tPROBLEM: result for wcscasecmp(\"%ls\", \"%ls\") = %d "
374 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
381 const wchar_t* a
= L
"TäSt";
382 const wchar_t* b
= L
"täs";
383 int result
= sign(wcscasecmp(a
, b
));
385 if (result
!= expected
|| errno
!= 0) {
386 printf("\tPROBLEM: result for wcscasecmp(\"%ls\", \"%ls\") = %d "
387 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
394 const wchar_t* a
= L
"tÄst1";
395 const wchar_t* b
= L
"täst0";
396 int result
= sign(wcsncasecmp(a
, b
, 0));
398 if (result
!= expected
|| errno
!= 0) {
399 printf("\tPROBLEM: result for wcscasencmp(\"%ls\", \"%ls\", 0) = %d"
400 " (expected %d), errno = %x (expected 0)\n", a
, b
, result
,
407 const wchar_t* a
= L
"täst1";
408 const wchar_t* b
= L
"täSt0";
409 int result
= sign(wcsncasecmp(a
, b
, 4));
411 if (result
!= expected
|| errno
!= 0) {
412 printf("\tPROBLEM: result for wcsncasecmp(\"%ls\", \"%ls\", 4) = %d"
413 " (expected %d), errno = %x (expected 0)\n", a
, b
, result
,
420 const wchar_t* a
= L
"täsT1";
421 const wchar_t* b
= L
"täst0";
422 int result
= sign(wcsncasecmp(a
, b
, 5));
424 if (result
!= expected
|| errno
!= 0) {
425 printf("\tPROBLEM: result for wcsncasecmp(\"%ls\", \"%ls\", 5) = %d"
426 " (expected %d), errno = %x (expected 0)\n", a
, b
, result
,
433 const wchar_t* a
= L
"täs";
434 const wchar_t* b
= L
"täSt123";
435 int result
= sign(wcsncasecmp(a
, b
, (size_t)-1));
437 if (result
!= expected
|| errno
!= 0) {
438 printf("\tPROBLEM: result for wcsncasecmp(\"%ls\", \"%ls\", -1) = "
439 "%d (expected %d), errno = %x (expected 0)\n", a
, b
, result
,
446 printf("\t%d problem(s) found!\n", problemCount
);
448 printf("\tall fine\n");
452 // #pragma mark - wcschr -------------------------------------------------------
458 printf("wcschr()/wcschrnul()/wcsrchr()\n");
460 int problemCount
= 0;
464 const wchar_t* string
= L
"";
465 const wchar_t ch
= L
' ';
466 const wchar_t* result
= wcschr(string
, ch
);
467 const wchar_t* expected
= NULL
;
468 if (result
!= expected
|| errno
!= 0) {
469 printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = %p "
470 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
471 result
, expected
, errno
);
477 const wchar_t* string
= L
"";
478 const wchar_t ch
= L
'\0';
479 const wchar_t* result
= wcschr(string
, ch
);
480 const wchar_t* expected
= string
;
481 if (result
!= expected
|| errno
!= 0) {
482 printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = %p "
483 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
484 result
, expected
, errno
);
490 const wchar_t* string
= L
"sometext";
491 const wchar_t ch
= L
' ';
492 const wchar_t* result
= wcschr(string
, ch
);
493 const wchar_t* expected
= NULL
;
494 if (result
!= expected
|| errno
!= 0) {
495 printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = %p "
496 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
497 result
, expected
, errno
);
503 const wchar_t* string
= L
"some more text";
504 const wchar_t ch
= L
' ';
505 const wchar_t* result
= wcschr(string
, ch
);
506 const wchar_t* expected
= string
+ 4;
507 if (result
!= expected
|| errno
!= 0) {
508 printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = %p "
509 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
510 result
, expected
, errno
);
516 const wchar_t* string
= L
"some more text";
517 const wchar_t ch
= L
's';
518 const wchar_t* result
= wcschr(string
, ch
);
519 const wchar_t* expected
= string
;
520 if (result
!= expected
|| errno
!= 0) {
521 printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = %p "
522 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
523 result
, expected
, errno
);
529 const wchar_t* string
= L
"some more text";
530 const wchar_t ch
= L
'S';
531 const wchar_t* result
= wcschr(string
, ch
);
532 const wchar_t* expected
= NULL
;
533 if (result
!= expected
|| errno
!= 0) {
534 printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = %p "
535 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
536 result
, expected
, errno
);
542 const wchar_t* string
= L
"some more text";
543 const wchar_t ch
= L
'\0';
544 const wchar_t* result
= wcschr(string
, ch
);
545 const wchar_t* expected
= string
+ 14;
546 if (result
!= expected
|| errno
!= 0) {
547 printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = %p "
548 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
549 result
, expected
, errno
);
555 const wchar_t* string
= L
"";
556 const wchar_t ch
= L
' ';
557 const wchar_t* result
= wcschrnul(string
, ch
);
558 const wchar_t* expected
= string
;
559 if (result
!= expected
|| errno
!= 0) {
560 printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') = %p "
561 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
562 result
, expected
, errno
);
568 const wchar_t* string
= L
"";
569 const wchar_t ch
= L
'\0';
570 const wchar_t* result
= wcschrnul(string
, ch
);
571 const wchar_t* expected
= string
;
572 if (result
!= expected
|| errno
!= 0) {
573 printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') = %p "
574 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
575 result
, expected
, errno
);
581 const wchar_t* string
= L
"sometext";
582 const wchar_t ch
= L
' ';
583 const wchar_t* result
= wcschrnul(string
, ch
);
584 const wchar_t* expected
= string
+ wcslen(string
);
585 if (result
!= expected
|| errno
!= 0) {
586 printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') = %p "
587 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
588 result
, expected
, errno
);
594 const wchar_t* string
= L
"some more text";
595 const wchar_t ch
= L
' ';
596 const wchar_t* result
= wcschrnul(string
, ch
);
597 const wchar_t* expected
= string
+ 4;
598 if (result
!= expected
|| errno
!= 0) {
599 printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') = %p "
600 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
601 result
, expected
, errno
);
607 const wchar_t* string
= L
"some more text";
608 const wchar_t ch
= L
's';
609 const wchar_t* result
= wcschrnul(string
, ch
);
610 const wchar_t* expected
= string
;
611 if (result
!= expected
|| errno
!= 0) {
612 printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') = %p "
613 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
614 result
, expected
, errno
);
620 const wchar_t* string
= L
"some more text";
621 const wchar_t ch
= L
'S';
622 const wchar_t* result
= wcschrnul(string
, ch
);
623 const wchar_t* expected
= string
+ wcslen(string
);
624 if (result
!= expected
|| errno
!= 0) {
625 printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') = %p "
626 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
627 result
, expected
, errno
);
633 const wchar_t* string
= L
"some more text";
634 const wchar_t ch
= L
'\0';
635 const wchar_t* result
= wcschrnul(string
, ch
);
636 const wchar_t* expected
= string
+ 14;
637 if (result
!= expected
|| errno
!= 0) {
638 printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') = %p "
639 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
640 result
, expected
, errno
);
646 const wchar_t* string
= L
"";
647 const wchar_t ch
= L
' ';
648 const wchar_t* result
= wcsrchr(string
, ch
);
649 const wchar_t* expected
= NULL
;
650 if (result
!= expected
|| errno
!= 0) {
651 printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = %p "
652 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
653 result
, expected
, errno
);
659 const wchar_t* string
= L
"";
660 const wchar_t ch
= L
'\0';
661 const wchar_t* result
= wcsrchr(string
, ch
);
662 const wchar_t* expected
= string
;
663 if (result
!= expected
|| errno
!= 0) {
664 printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = %p "
665 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
666 result
, expected
, errno
);
672 const wchar_t* string
= L
"sometext";
673 const wchar_t ch
= L
' ';
674 const wchar_t* result
= wcsrchr(string
, ch
);
675 const wchar_t* expected
= NULL
;
676 if (result
!= expected
|| errno
!= 0) {
677 printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = %p "
678 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
679 result
, expected
, errno
);
685 const wchar_t* string
= L
"some more text";
686 const wchar_t ch
= L
' ';
687 const wchar_t* result
= wcsrchr(string
, ch
);
688 const wchar_t* expected
= string
+ 9;
689 if (result
!= expected
|| errno
!= 0) {
690 printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = %p "
691 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
692 result
, expected
, errno
);
698 const wchar_t* string
= L
"some more text";
699 const wchar_t ch
= L
's';
700 const wchar_t* result
= wcsrchr(string
, ch
);
701 const wchar_t* expected
= string
;
702 if (result
!= expected
|| errno
!= 0) {
703 printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = %p "
704 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
705 result
, expected
, errno
);
711 const wchar_t* string
= L
"some more text";
712 const wchar_t ch
= L
'S';
713 const wchar_t* result
= wcsrchr(string
, ch
);
714 const wchar_t* expected
= NULL
;
715 if (result
!= expected
|| errno
!= 0) {
716 printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = %p "
717 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
718 result
, expected
, errno
);
724 const wchar_t* string
= L
"some more text";
725 const wchar_t ch
= L
'\0';
726 const wchar_t* result
= wcsrchr(string
, ch
);
727 const wchar_t* expected
= string
+ 14;
728 if (result
!= expected
|| errno
!= 0) {
729 printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = %p "
730 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
731 result
, expected
, errno
);
737 printf("\t%d problem(s) found!\n", problemCount
);
739 printf("\tall fine\n");
743 // #pragma mark - wcsdup -------------------------------------------------------
749 printf("wcsdup()\n");
751 int problemCount
= 0;
756 const wchar_t* string
= NULL
;
757 wchar_t* result
= wcsdup(string
);
758 if (result
!= NULL
|| errno
!= 0) {
759 printf("\tPROBLEM: result for wcsdup(%p) = \"%ls\", errno = %x"
760 " (expected 0)\n", string
, result
, errno
);
767 const wchar_t* string
= L
"";
768 wchar_t* result
= wcsdup(string
);
769 if (result
== NULL
|| wcscmp(result
, string
) != 0 || errno
!= 0) {
770 printf("\tPROBLEM: result for wcsdup(\"%ls\") = \"%ls\", errno = %x"
771 " (expected 0)\n", string
, result
, errno
);
777 const wchar_t* string
= L
"tÄstdata with some charäcters";
778 wchar_t* result
= wcsdup(string
);
779 if (result
== NULL
|| wcscmp(result
, string
) != 0 || errno
!= 0) {
780 printf("\tPROBLEM: result for wcsdup(\"%ls\") = \"%ls\", errno = %x"
781 " (expected 0)\n", string
, result
, errno
);
787 printf("\t%d problem(s) found!\n", problemCount
);
789 printf("\tall fine\n");
793 // #pragma mark - wcscpy -------------------------------------------------------
799 printf("wcscpy()/wcsncpy()\n");
801 int problemCount
= 0;
805 const wchar_t* source
= L
"";
806 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
807 wchar_t* result
= wcscpy(destination
, source
);
808 if (result
!= destination
) {
809 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> result=%p, "
810 "expected %p\n", source
, result
, destination
);
814 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> errno=%d, "
815 "expected 0\n", source
, errno
);
818 if (wcslen(destination
) != 0) {
819 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
820 "wcslen(destination)=%lu, expected 0\n", source
,
821 wcslen(destination
));
824 if (destination
[0] != L
'\0') {
825 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
826 "destination[0]=%x, expected %x\n", source
, destination
[0],
830 if (destination
[1] != L
'X') {
831 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
832 "destination[1]=%x, expected %x\n", source
, destination
[1],
839 const wchar_t* source
= L
"test";
840 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
841 wchar_t* result
= wcscpy(destination
, source
);
842 if (result
!= destination
) {
843 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> result=%p, "
844 "expected %p\n", source
, result
, destination
);
848 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> errno=%d, "
849 "expected 0\n", source
, errno
);
852 if (wcslen(destination
) != 4) {
853 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
854 "wcslen(destination)=%lu, expected 4\n", source
,
855 wcslen(destination
));
858 if (destination
[0] != L
't') {
859 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
860 "destination[0]=%x, expected %x\n", source
, destination
[0],
864 if (destination
[1] != L
'e') {
865 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
866 "destination[1]=%x, expected %x\n", source
, destination
[1],
870 if (destination
[2] != L
's') {
871 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
872 "destination[2]=%x, expected %x\n", source
, destination
[2],
876 if (destination
[3] != L
't') {
877 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
878 "destination[3]=%x, expected %x\n", source
, destination
[3],
882 if (destination
[4] != L
'\0') {
883 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
884 "destination[4]=%x, expected %x\n", source
, destination
[4],
888 if (destination
[5] != L
'X') {
889 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
890 "destination[5]=%x, expected %x\n", source
, destination
[5],
897 const wchar_t* source
= L
"t\xE4st";
898 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
899 wchar_t* result
= wcscpy(destination
, source
);
900 if (result
!= destination
) {
901 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> result=%p, "
902 "expected %p\n", source
, result
, destination
);
906 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> errno=%d, "
907 "expected 0\n", source
, errno
);
910 if (wcslen(destination
) != 4) {
911 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
912 "wcslen(destination)=%lu, expected 4\n", source
,
913 wcslen(destination
));
916 if (destination
[0] != L
't') {
917 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
918 "destination[0]=%x, expected %x\n", source
, destination
[0],
922 if (destination
[1] != L
'\xE4') {
923 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
924 "destination[1]=%x, expected %x\n", source
, destination
[1],
928 if (destination
[2] != L
's') {
929 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
930 "destination[2]=%x, expected %x\n", source
, destination
[2],
934 if (destination
[3] != L
't') {
935 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
936 "destination[3]=%x, expected %x\n", source
, destination
[3],
940 if (destination
[4] != L
'\0') {
941 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
942 "destination[4]=%x, expected %x\n", source
, destination
[4],
946 if (destination
[5] != L
'X') {
947 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
948 "destination[5]=%x, expected %x\n", source
, destination
[5],
955 const wchar_t* source
= L
"te\x00st";
956 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
957 wchar_t* result
= wcscpy(destination
, source
);
958 if (result
!= destination
) {
959 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> result=%p, "
960 "expected %p\n", source
, result
, destination
);
964 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> errno=%d, "
965 "expected 0\n", source
, errno
);
968 if (wcslen(destination
) != 2) {
969 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
970 "wcslen(destination)=%lu, expected 2\n", source
,
971 wcslen(destination
));
974 if (destination
[0] != L
't') {
975 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
976 "destination[0]=%x, expected %x\n", source
, destination
[0],
980 if (destination
[1] != L
'e') {
981 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
982 "destination[1]=%x, expected %x\n", source
, destination
[1],
986 if (destination
[2] != L
'\0') {
987 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
988 "destination[2]=%x, expected %x\n", source
, destination
[2],
992 if (destination
[3] != L
'X') {
993 printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
994 "destination[3]=%x, expected %x\n", source
, destination
[3],
1001 const wchar_t* source
= L
"t\xE4st";
1002 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1003 wchar_t* result
= wcsncpy(destination
, source
, 0);
1004 if (result
!= destination
) {
1005 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 0) -> result=%p, "
1006 "expected %p\n", source
, result
, destination
);
1010 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 0) -> errno=%d, "
1011 "expected 0\n", source
, errno
);
1014 if (destination
[0] != L
'X') {
1015 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 0) -> "
1016 "destination[0]=%x, expected %x\n", source
, destination
[0],
1023 const wchar_t* source
= L
"t\xE4st";
1024 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1025 wchar_t* result
= wcsncpy(destination
, source
, 2);
1026 if (result
!= destination
) {
1027 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> result=%p, "
1028 "expected %p\n", source
, result
, destination
);
1032 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> errno=%d, "
1033 "expected 0\n", source
, errno
);
1036 if (destination
[0] != L
't') {
1037 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> "
1038 "destination[0]=%x, expected %x\n", source
, destination
[0],
1042 if (destination
[1] != L
'\xE4') {
1043 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> "
1044 "destination[1]=%x, expected %x\n", source
, destination
[1],
1048 if (destination
[2] != L
'X') {
1049 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> "
1050 "destination[2]=%x, expected %x\n", source
, destination
[2],
1057 const wchar_t* source
= L
"t\xE4st";
1058 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1059 wchar_t* result
= wcsncpy(destination
, source
, 4);
1060 if (result
!= destination
) {
1061 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> result=%p, "
1062 "expected %p\n", source
, result
, destination
);
1066 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> errno=%d, "
1067 "expected 0\n", source
, errno
);
1070 if (destination
[0] != L
't') {
1071 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
1072 "destination[0]=%x, expected %x\n", source
, destination
[0],
1076 if (destination
[1] != L
'\xE4') {
1077 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
1078 "destination[1]=%x, expected %x\n", source
, destination
[1],
1082 if (destination
[2] != L
's') {
1083 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
1084 "destination[2]=%x, expected %x\n", source
, destination
[2],
1088 if (destination
[3] != L
't') {
1089 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
1090 "destination[3]=%x, expected %x\n", source
, destination
[3],
1094 if (destination
[4] != L
'X') {
1095 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
1096 "destination[4]=%x, expected %x\n", source
, destination
[4],
1103 const wchar_t* source
= L
"t\xE4st";
1104 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1105 wchar_t* result
= wcsncpy(destination
, source
, 8);
1106 if (result
!= destination
) {
1107 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> result=%p, "
1108 "expected %p\n", source
, result
, destination
);
1112 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> errno=%d, "
1113 "expected 0\n", source
, errno
);
1116 if (wcslen(destination
) != 4) {
1117 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1118 "wcslen(destination)=%lu, expected 4\n", source
,
1119 wcslen(destination
));
1122 if (destination
[0] != L
't') {
1123 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1124 "destination[0]=%x, expected %x\n", source
, destination
[0],
1128 if (destination
[1] != L
'\xE4') {
1129 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1130 "destination[1]=%x, expected %x\n", source
, destination
[1],
1134 if (destination
[2] != L
's') {
1135 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1136 "destination[2]=%x, expected %x\n", source
, destination
[2],
1140 if (destination
[3] != L
't') {
1141 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1142 "destination[3]=%x, expected %x\n", source
, destination
[3],
1146 if (destination
[4] != L
'\0') {
1147 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1148 "destination[4]=%x, expected %x\n", source
, destination
[4],
1152 if (destination
[5] != L
'\0') {
1153 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1154 "destination[5]=%x, expected %x\n", source
, destination
[5],
1158 if (destination
[6] != L
'\0') {
1159 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1160 "destination[6]=%x, expected %x\n", source
, destination
[6],
1164 if (destination
[7] != L
'\0') {
1165 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1166 "destination[7]=%x, expected %x\n", source
, destination
[7],
1170 if (destination
[8] != L
'X') {
1171 printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
1172 "destination[8]=%x, expected %x\n", source
, destination
[8],
1179 printf("\t%d problem(s) found!\n", problemCount
);
1181 printf("\tall fine\n");
1185 // #pragma mark - wcpcpy -------------------------------------------------------
1191 printf("wcpcpy()/wcpncpy()\n");
1193 int problemCount
= 0;
1197 const wchar_t* source
= L
"";
1198 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1199 wchar_t* result
= wcpcpy(destination
, source
);
1200 if (result
!= destination
) {
1201 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> result=%p, "
1202 "expected %p\n", source
, result
, destination
);
1206 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> errno=%d, "
1207 "expected 0\n", source
, errno
);
1210 if (wcslen(destination
) != 0) {
1211 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1212 "wcslen(destination)=%lu, expected 0\n", source
,
1213 wcslen(destination
));
1216 if (destination
[0] != L
'\0') {
1217 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1218 "destination[0]=%x, expected %x\n", source
, destination
[0],
1222 if (destination
[1] != L
'X') {
1223 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1224 "destination[1]=%x, expected %x\n", source
, destination
[1],
1231 const wchar_t* source
= L
"test";
1232 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1233 wchar_t* result
= wcpcpy(destination
, source
);
1234 if (result
!= destination
+ 4) {
1235 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> result=%p, "
1236 "expected %p\n", source
, result
, destination
+ 4);
1240 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> errno=%d, "
1241 "expected 0\n", source
, errno
);
1244 if (wcslen(destination
) != 4) {
1245 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1246 "wcslen(destination)=%lu, expected 4\n", source
,
1247 wcslen(destination
));
1250 if (destination
[0] != L
't') {
1251 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1252 "destination[0]=%x, expected %x\n", source
, destination
[0],
1256 if (destination
[1] != L
'e') {
1257 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1258 "destination[1]=%x, expected %x\n", source
, destination
[1],
1262 if (destination
[2] != L
's') {
1263 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1264 "destination[2]=%x, expected %x\n", source
, destination
[2],
1268 if (destination
[3] != L
't') {
1269 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1270 "destination[3]=%x, expected %x\n", source
, destination
[3],
1274 if (destination
[4] != L
'\0') {
1275 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1276 "destination[4]=%x, expected %x\n", source
, destination
[4],
1280 if (destination
[5] != L
'X') {
1281 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1282 "destination[5]=%x, expected %x\n", source
, destination
[5],
1289 const wchar_t* source
= L
"t\xE4st";
1290 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1291 wchar_t* result
= wcpcpy(destination
, source
);
1292 if (result
!= destination
+ 4) {
1293 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> result=%p, "
1294 "expected %p\n", source
, result
, destination
+ 4);
1298 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> errno=%d, "
1299 "expected 0\n", source
, errno
);
1302 if (wcslen(destination
) != 4) {
1303 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1304 "wcslen(destination)=%lu, expected 4\n", source
,
1305 wcslen(destination
));
1308 if (destination
[0] != L
't') {
1309 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1310 "destination[0]=%x, expected %x\n", source
, destination
[0],
1314 if (destination
[1] != L
'\xE4') {
1315 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1316 "destination[1]=%x, expected %x\n", source
, destination
[1],
1320 if (destination
[2] != L
's') {
1321 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1322 "destination[2]=%x, expected %x\n", source
, destination
[2],
1326 if (destination
[3] != L
't') {
1327 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1328 "destination[3]=%x, expected %x\n", source
, destination
[3],
1332 if (destination
[4] != L
'\0') {
1333 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1334 "destination[4]=%x, expected %x\n", source
, destination
[4],
1338 if (destination
[5] != L
'X') {
1339 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1340 "destination[5]=%x, expected %x\n", source
, destination
[5],
1347 const wchar_t* source
= L
"te\x00st";
1348 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1349 wchar_t* result
= wcpcpy(destination
, source
);
1350 if (result
!= destination
+ 2) {
1351 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> result=%p, "
1352 "expected %p\n", source
, result
, destination
+ 2);
1356 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> errno=%d, "
1357 "expected 0\n", source
, errno
);
1360 if (wcslen(destination
) != 2) {
1361 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1362 "wcslen(destination)=%lu, expected 2\n", source
,
1363 wcslen(destination
));
1366 if (destination
[0] != L
't') {
1367 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1368 "destination[0]=%x, expected %x\n", source
, destination
[0],
1372 if (destination
[1] != L
'e') {
1373 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1374 "destination[1]=%x, expected %x\n", source
, destination
[1],
1378 if (destination
[2] != L
'\0') {
1379 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1380 "destination[2]=%x, expected %x\n", source
, destination
[2],
1384 if (destination
[3] != L
'X') {
1385 printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
1386 "destination[3]=%x, expected %x\n", source
, destination
[3],
1393 const wchar_t* source
= L
"t\xE4st";
1394 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1395 wchar_t* result
= wcpncpy(destination
, source
, 0);
1396 if (result
!= destination
) {
1397 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 0) -> result=%p, "
1398 "expected %p\n", source
, result
, destination
);
1402 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 0) -> errno=%d, "
1403 "expected 0\n", source
, errno
);
1406 if (destination
[0] != L
'X') {
1407 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 0) -> "
1408 "destination[0]=%x, expected %x\n", source
, destination
[0],
1415 const wchar_t* source
= L
"t\xE4st";
1416 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1417 wchar_t* result
= wcpncpy(destination
, source
, 2);
1418 if (result
!= destination
+ 2) {
1419 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> result=%p, "
1420 "expected %p\n", source
, result
, destination
+ 2);
1424 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> errno=%d, "
1425 "expected 0\n", source
, errno
);
1428 if (destination
[0] != L
't') {
1429 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> "
1430 "destination[0]=%x, expected %x\n", source
, destination
[0],
1434 if (destination
[1] != L
'\xE4') {
1435 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> "
1436 "destination[1]=%x, expected %x\n", source
, destination
[1],
1440 if (destination
[2] != L
'X') {
1441 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> "
1442 "destination[2]=%x, expected %x\n", source
, destination
[2],
1449 const wchar_t* source
= L
"t\xE4st";
1450 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1451 wchar_t* result
= wcpncpy(destination
, source
, 4);
1452 if (result
!= destination
+ 4) {
1453 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> result=%p, "
1454 "expected %p\n", source
, result
, destination
+ 4);
1458 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> errno=%d, "
1459 "expected 0\n", source
, errno
);
1462 if (destination
[0] != L
't') {
1463 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
1464 "destination[0]=%x, expected %x\n", source
, destination
[0],
1468 if (destination
[1] != L
'\xE4') {
1469 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
1470 "destination[1]=%x, expected %x\n", source
, destination
[1],
1474 if (destination
[2] != L
's') {
1475 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
1476 "destination[2]=%x, expected %x\n", source
, destination
[2],
1480 if (destination
[3] != L
't') {
1481 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
1482 "destination[3]=%x, expected %x\n", source
, destination
[3],
1486 if (destination
[4] != L
'X') {
1487 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
1488 "destination[4]=%x, expected %x\n", source
, destination
[4],
1495 const wchar_t* source
= L
"t\xE4st";
1496 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
1497 wchar_t* result
= wcpncpy(destination
, source
, 8);
1498 if (result
!= destination
+ 4) {
1499 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> result=%p, "
1500 "expected %p\n", source
, result
, destination
+ 4);
1504 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> errno=%d, "
1505 "expected 0\n", source
, errno
);
1508 if (wcslen(destination
) != 4) {
1509 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1510 "wcslen(destination)=%lu, expected 4\n", source
,
1511 wcslen(destination
));
1514 if (destination
[0] != L
't') {
1515 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1516 "destination[0]=%x, expected %x\n", source
, destination
[0],
1520 if (destination
[1] != L
'\xE4') {
1521 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1522 "destination[1]=%x, expected %x\n", source
, destination
[1],
1526 if (destination
[2] != L
's') {
1527 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1528 "destination[2]=%x, expected %x\n", source
, destination
[2],
1532 if (destination
[3] != L
't') {
1533 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1534 "destination[3]=%x, expected %x\n", source
, destination
[3],
1538 if (destination
[4] != L
'\0') {
1539 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1540 "destination[4]=%x, expected %x\n", source
, destination
[4],
1544 if (destination
[5] != L
'\0') {
1545 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1546 "destination[5]=%x, expected %x\n", source
, destination
[5],
1550 if (destination
[6] != L
'\0') {
1551 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1552 "destination[6]=%x, expected %x\n", source
, destination
[6],
1556 if (destination
[7] != L
'\0') {
1557 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1558 "destination[7]=%x, expected %x\n", source
, destination
[7],
1562 if (destination
[8] != L
'X') {
1563 printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
1564 "destination[8]=%x, expected %x\n", source
, destination
[8],
1571 printf("\t%d problem(s) found!\n", problemCount
);
1573 printf("\tall fine\n");
1577 // #pragma mark - wcscat -------------------------------------------------------
1583 printf("wcscat()/wcsncat()\n");
1585 int problemCount
= 0;
1587 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
1588 destination
[0] = L
'\0';
1592 wcscpy(backup
, destination
);
1593 const wchar_t* source
= L
"";
1594 wchar_t* result
= wcscat(destination
, source
);
1595 if (result
!= destination
) {
1596 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> result=%p, "
1597 "expected %p\n", backup
, source
, result
, destination
);
1601 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> errno=%d, "
1602 "expected 0\n", backup
, source
, errno
);
1605 if (wcslen(destination
) != 0) {
1606 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> "
1607 "wcslen(destination)=%lu, expected 0\n", backup
, source
,
1608 wcslen(destination
));
1611 if (destination
[0] != L
'\0') {
1612 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[0]=%x, "
1613 "expected %x\n", backup
, source
, destination
[0], L
'\0');
1616 if (destination
[1] != L
'X') {
1617 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[1]=%x, "
1618 "expected %x\n", backup
, source
, destination
[1], L
'X');
1624 wcscpy(backup
, destination
);
1625 const wchar_t* source
= L
"test";
1626 wchar_t* result
= wcscat(destination
, source
);
1627 if (result
!= destination
) {
1628 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> result=%p, "
1629 "expected %p\n", backup
, source
, result
, destination
);
1633 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> errno=%d, "
1634 "expected 0\n", backup
, source
, errno
);
1637 if (wcslen(destination
) != 4) {
1638 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> "
1639 "wcslen(destination)=%lu, expected 4\n", backup
, source
,
1640 wcslen(destination
));
1643 if (destination
[0] != L
't') {
1644 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[0]=%x, "
1645 "expected %x\n", backup
, source
, destination
[0], L
't');
1648 if (destination
[1] != L
'e') {
1649 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[1]=%x, "
1650 "expected %x\n", backup
, source
, destination
[1], L
'e');
1653 if (destination
[2] != L
's') {
1654 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[2]=%x, "
1655 "expected %x\n", backup
, source
, destination
[2], L
's');
1658 if (destination
[3] != L
't') {
1659 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[3]=%x, "
1660 "expected %x\n", backup
, source
, destination
[3], L
't');
1663 if (destination
[4] != L
'\0') {
1664 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[4]=%x, "
1665 "expected %x\n", backup
, source
, destination
[4], L
'\0');
1668 if (destination
[5] != L
'X') {
1669 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[5]=%x, "
1670 "expected %x\n", backup
, source
, destination
[5], L
'X');
1676 wcscpy(backup
, destination
);
1677 const wchar_t* source
= L
"t\xE4st";
1678 wchar_t* result
= wcscat(destination
, source
);
1679 if (result
!= destination
) {
1680 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> result=%p, "
1681 "expected %p\n", backup
, source
, result
, destination
);
1685 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> errno=%d, "
1686 "expected 0\n", backup
, source
, errno
);
1689 if (wcslen(destination
) != 8) {
1690 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> "
1691 "wcslen(destination)=%lu, expected 8\n", backup
, source
,
1692 wcslen(destination
));
1695 if (destination
[0] != L
't') {
1696 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[0]=%x, "
1697 "expected %x\n", backup
, source
, destination
[0], L
't');
1700 if (destination
[1] != L
'e') {
1701 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[1]=%x, "
1702 "expected %x\n", backup
, source
, destination
[1], L
'e');
1705 if (destination
[2] != L
's') {
1706 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[2]=%x, "
1707 "expected %x\n", backup
, source
, destination
[2], L
's');
1710 if (destination
[3] != L
't') {
1711 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[3]=%x, "
1712 "expected %x\n", backup
, source
, destination
[3], L
't');
1715 if (destination
[4] != L
't') {
1716 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[4]=%x, "
1717 "expected %x\n", backup
, source
, destination
[4], L
't');
1720 if (destination
[5] != L
'\xE4') {
1721 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[5]=%x, "
1722 "expected %x\n", backup
, source
, destination
[5], L
'\xE4');
1725 if (destination
[6] != L
's') {
1726 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[6]=%x, "
1727 "expected %x\n", backup
, source
, destination
[6], L
's');
1730 if (destination
[7] != L
't') {
1731 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[7]=%x, "
1732 "expected %x\n", backup
, source
, destination
[7], L
't');
1735 if (destination
[8] != L
'\0') {
1736 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[8]=%x, "
1737 "expected %x\n", backup
, source
, destination
[8], L
'\0');
1740 if (destination
[9] != L
'X') {
1741 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[9]=%x, "
1742 "expected %x\n", backup
, source
, destination
[9], L
'X');
1748 wcscpy(backup
, destination
);
1749 const wchar_t* source
= L
"te\x00st";
1750 wchar_t* result
= wcscat(destination
, source
);
1751 if (result
!= destination
) {
1752 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> result=%p, "
1753 "expected %p\n", backup
, source
, result
, destination
);
1757 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> errno=%d, "
1758 "expected 0\n", backup
, source
, errno
);
1761 if (wcslen(destination
) != 10) {
1762 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> "
1763 "wcslen(destination)=%lu, expected 10\n", backup
, source
,
1764 wcslen(destination
));
1767 if (destination
[0] != L
't') {
1768 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[0]=%x, "
1769 "expected %x\n", backup
, source
, destination
[0], L
't');
1772 if (destination
[1] != L
'e') {
1773 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[1]=%x, "
1774 "expected %x\n", backup
, source
, destination
[1], L
'e');
1777 if (destination
[2] != L
's') {
1778 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[2]=%x, "
1779 "expected %x\n", backup
, source
, destination
[2], L
's');
1782 if (destination
[3] != L
't') {
1783 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[3]=%x, "
1784 "expected %x\n", backup
, source
, destination
[3], L
't');
1787 if (destination
[4] != L
't') {
1788 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[4]=%x, "
1789 "expected %x\n", backup
, source
, destination
[4], L
't');
1792 if (destination
[5] != L
'\xE4') {
1793 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[5]=%x, "
1794 "expected %x\n", backup
, source
, destination
[5], L
'\xE4');
1797 if (destination
[6] != L
's') {
1798 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[6]=%x, "
1799 "expected %x\n", backup
, source
, destination
[6], L
's');
1802 if (destination
[7] != L
't') {
1803 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[7]=%x, "
1804 "expected %x\n", backup
, source
, destination
[7], L
't');
1807 if (destination
[8] != L
't') {
1808 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[8]=%x, "
1809 "expected %x\n", backup
, source
, destination
[8], L
't');
1812 if (destination
[9] != L
'e') {
1813 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[9]=%x, "
1814 "expected %x\n", backup
, source
, destination
[9], L
'e');
1817 if (destination
[10] != L
'\0') {
1818 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[10]=%x, "
1819 "expected %x\n", backup
, source
, destination
[10], L
'\0');
1822 if (destination
[11] != L
'X') {
1823 printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> destination[11]=%x, "
1824 "expected %x\n", backup
, source
, destination
[11], L
'X');
1830 wcscpy(destination
, L
"some");
1831 wcscpy(backup
, destination
);
1832 const wchar_t* source
= L
" other text";
1833 wchar_t* result
= wcsncat(destination
, source
, 0);
1834 if (result
!= destination
) {
1835 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 0) -> result=%p, "
1836 "expected %p\n", backup
, source
, result
, destination
);
1840 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 0) -> errno=%d, "
1841 "expected 0\n", backup
, source
, errno
);
1844 if (wcslen(destination
) != 4) {
1845 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 0) -> "
1846 "wcslen(destination)=%lu, expected 4\n", backup
, source
,
1847 wcslen(destination
));
1850 if (wcscmp(destination
, L
"some") != 0) {
1851 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 0) -> \"%ls\"\n",
1852 backup
, source
, destination
);
1858 wcscpy(destination
, L
"some");
1859 wcscpy(backup
, destination
);
1860 const wchar_t* source
= L
" other text";
1861 wchar_t* result
= wcsncat(destination
, source
, 6);
1862 if (result
!= destination
) {
1863 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 6) -> result=%p, "
1864 "expected %p\n", backup
, source
, result
, destination
);
1868 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 6) -> errno=%d, "
1869 "expected 0\n", backup
, source
, errno
);
1872 if (wcslen(destination
) != 10) {
1873 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 6) -> "
1874 "wcslen(destination)=%lu, expected 10\n", backup
, source
,
1875 wcslen(destination
));
1878 if (wcscmp(destination
, L
"some other") != 0) {
1879 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 6) -> \"%ls\"\n",
1880 backup
, source
, destination
);
1886 wcscpy(destination
, L
"some");
1887 wcscpy(backup
, destination
);
1888 const wchar_t* source
= L
" other text";
1889 wchar_t* result
= wcsncat(destination
, source
, 20);
1890 if (result
!= destination
) {
1891 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 20) -> result=%p, "
1892 "expected %p\n", backup
, source
, result
, destination
);
1896 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 20) -> errno=%d, "
1897 "expected 0\n", backup
, source
, errno
);
1900 if (wcslen(destination
) != 15) {
1901 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 20) -> "
1902 "wcslen(destination)=%lu, expected 15\n", backup
, source
,
1903 wcslen(destination
));
1906 if (wcscmp(destination
, L
"some other text") != 0) {
1907 printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 20) -> \"%ls\"\n",
1908 backup
, source
, destination
);
1914 printf("\t%d problem(s) found!\n", problemCount
);
1916 printf("\tall fine\n");
1920 // #pragma mark - wcslcat ------------------------------------------------------
1928 printf("wcslcat()\n");
1930 int problemCount
= 0;
1932 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
1936 wcscpy(backup
, destination
);
1937 const wchar_t* source
= L
"";
1938 size_t result
= wcslcat(destination
, source
, 0);
1939 size_t expectedResult
= 0;
1940 if (result
!= expectedResult
) {
1941 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 0) -> result=%ld, "
1942 "expected %ld\n", backup
, source
, result
, expectedResult
);
1946 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 0) -> errno=%d, "
1947 "expected 0\n", backup
, source
, errno
);
1950 if (wcslen(destination
) != 32) {
1951 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 0) -> "
1952 "wcslen(destination)=%lu, expected 32\n", backup
, source
,
1953 wcslen(destination
));
1956 if (destination
[0] != L
'X') {
1957 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 0) -> destination[0]="
1958 "%x, expected %x\n", backup
, source
, destination
[0], L
'X');
1964 destination
[0] = L
'\0';
1965 wcscpy(backup
, destination
);
1966 const wchar_t* source
= L
"";
1967 size_t result
= wcslcat(destination
, source
, 32);
1968 size_t expectedResult
= 0;
1969 if (result
!= expectedResult
) {
1970 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> result=%ld, "
1971 "expected %ld\n", backup
, source
, result
, expectedResult
);
1975 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> errno=%d, "
1976 "expected 0\n", backup
, source
, errno
);
1979 if (wcslen(destination
) != 0) {
1980 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> "
1981 "wcslen(destination)=%lu, expected 0\n", backup
, source
,
1982 wcslen(destination
));
1985 if (destination
[0] != L
'\0') {
1986 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[0]="
1987 "%x, expected %x\n", backup
, source
, destination
[0], L
'\0');
1990 if (destination
[1] != L
'X') {
1991 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[1]="
1992 "%x, expected %x\n", backup
, source
, destination
[1], L
'X');
1998 wcscpy(backup
, destination
);
1999 const wchar_t* source
= L
"test";
2000 size_t result
= wcslcat(destination
, source
, 3);
2001 size_t expectedResult
= 4;
2002 if (result
!= expectedResult
) {
2003 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> result=%ld, "
2004 "expected %ld\n", backup
, source
, result
, expectedResult
);
2008 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> errno=%d, "
2009 "expected 0\n", backup
, source
, errno
);
2012 if (wcslen(destination
) != 2) {
2013 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> "
2014 "wcslen(destination)=%lu, expected 2\n", backup
, source
,
2015 wcslen(destination
));
2018 if (destination
[0] != L
't') {
2019 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> destination[0]="
2020 "%x, expected %x\n", backup
, source
, destination
[0], L
't');
2023 if (destination
[1] != L
'e') {
2024 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> destination[1]="
2025 "%x, expected %x\n", backup
, source
, destination
[1], L
'e');
2028 if (destination
[2] != L
'\0') {
2029 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> destination[2]="
2030 "%x, expected %x\n", backup
, source
, destination
[2], L
'\0');
2033 if (destination
[3] != L
'X') {
2034 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> destination[3]="
2035 "%x, expected %x\n", backup
, source
, destination
[3], L
'X');
2041 wcscpy(backup
, destination
);
2042 const wchar_t* source
= L
"st";
2043 size_t result
= wcslcat(destination
, source
, 4);
2044 size_t expectedResult
= 4;
2045 if (result
!= expectedResult
) {
2046 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> result=%ld, "
2047 "expected %ld\n", backup
, source
, result
, expectedResult
);
2051 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> errno=%d, "
2052 "expected 0\n", backup
, source
, errno
);
2055 if (wcslen(destination
) != 3) {
2056 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> "
2057 "wcslen(destination)=%lu, expected 3\n", backup
, source
,
2058 wcslen(destination
));
2061 if (destination
[0] != L
't') {
2062 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> destination[0]="
2063 "%x, expected %x\n", backup
, source
, destination
[0], L
't');
2066 if (destination
[1] != L
'e') {
2067 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> destination[1]="
2068 "%x, expected %x\n", backup
, source
, destination
[1], L
'e');
2071 if (destination
[2] != L
's') {
2072 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> destination[2]="
2073 "%x, expected %x\n", backup
, source
, destination
[2], L
's');
2076 if (destination
[3] != L
'\0') {
2077 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> destination[3]="
2078 "%x, expected %x\n", backup
, source
, destination
[3], L
'\0');
2081 if (destination
[4] != L
'X') {
2082 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> destination[4]="
2083 "%x, expected %x\n", backup
, source
, destination
[4], L
'X');
2089 wcscpy(backup
, destination
);
2090 const wchar_t* source
= L
"t";
2091 size_t result
= wcslcat(destination
, source
, 5);
2092 size_t expectedResult
= 4;
2093 if (result
!= expectedResult
) {
2094 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> result=%ld, "
2095 "expected %ld\n", backup
, source
, result
, expectedResult
);
2099 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> errno=%d, "
2100 "expected 0\n", backup
, source
, errno
);
2103 if (wcslen(destination
) != 4) {
2104 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> "
2105 "wcslen(destination)=%lu, expected 4\n", backup
, source
,
2106 wcslen(destination
));
2109 if (destination
[0] != L
't') {
2110 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> destination[0]="
2111 "%x, expected %x\n", backup
, source
, destination
[0], L
't');
2114 if (destination
[1] != L
'e') {
2115 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> destination[1]="
2116 "%x, expected %x\n", backup
, source
, destination
[1], L
'e');
2119 if (destination
[2] != L
's') {
2120 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> destination[2]="
2121 "%x, expected %x\n", backup
, source
, destination
[2], L
's');
2124 if (destination
[3] != L
't') {
2125 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> destination[3]="
2126 "%x, expected %x\n", backup
, source
, destination
[3], L
't');
2129 if (destination
[4] != L
'\0') {
2130 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> destination[4]="
2131 "%x, expected %x\n", backup
, source
, destination
[4], L
'\0');
2134 if (destination
[5] != L
'X') {
2135 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> destination[5]="
2136 "%x, expected %x\n", backup
, source
, destination
[5], L
'X');
2142 wcscpy(backup
, destination
);
2143 const wchar_t* source
= L
"t\xE4st";
2144 size_t result
= wcslcat(destination
, source
, 32);
2145 size_t expectedResult
= 8;
2146 if (result
!= expectedResult
) {
2147 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> result=%ld, "
2148 "expected %ld\n", backup
, source
, result
, expectedResult
);
2152 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> errno=%d, "
2153 "expected 0\n", backup
, source
, errno
);
2156 if (wcslen(destination
) != 8) {
2157 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> "
2158 "wcslen(destination)=%lu, expected 8\n", backup
, source
,
2159 wcslen(destination
));
2162 if (destination
[0] != L
't') {
2163 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[0]="
2164 "%x, expected %x\n", backup
, source
, destination
[0], L
't');
2167 if (destination
[1] != L
'e') {
2168 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[1]="
2169 "%x, expected %x\n", backup
, source
, destination
[1], L
'e');
2172 if (destination
[2] != L
's') {
2173 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[2]="
2174 "%x, expected %x\n", backup
, source
, destination
[2], L
's');
2177 if (destination
[3] != L
't') {
2178 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[3]="
2179 "%x, expected %x\n", backup
, source
, destination
[3], L
't');
2182 if (destination
[4] != L
't') {
2183 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[4]="
2184 "%x, expected %x\n", backup
, source
, destination
[4], L
't');
2187 if (destination
[5] != L
'\xE4') {
2188 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[5]="
2189 "%x, expected %x\n", backup
, source
, destination
[5],
2193 if (destination
[6] != L
's') {
2194 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[6]="
2195 "%x, expected %x\n", backup
, source
, destination
[6], L
's');
2198 if (destination
[7] != L
't') {
2199 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[7]="
2200 "%x, expected %x\n", backup
, source
, destination
[7], L
't');
2203 if (destination
[8] != L
'\0') {
2204 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[8]="
2205 "%x, expected %x\n", backup
, source
, destination
[8], L
'\0');
2208 if (destination
[9] != L
'X') {
2209 printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> destination[9]="
2210 "%x, expected %x\n", backup
, source
, destination
[9], L
'X');
2216 printf("\t%d problem(s) found!\n", problemCount
);
2218 printf("\tall fine\n");
2224 // #pragma mark - wcslcpy ------------------------------------------------------
2232 printf("wcslcpy()\n");
2234 int problemCount
= 0;
2238 const wchar_t* source
= L
"";
2239 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
2241 size_t result
= wcslcpy(destination
, source
, 0);
2242 size_t expectedResult
= 0;
2243 if (result
!= expectedResult
) {
2244 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 0) -> result=%ld, "
2245 "expected %ld\n", source
, result
, expectedResult
);
2249 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 0) -> errno=%d, "
2250 "expected 0\n", source
, errno
);
2253 if (wcslen(destination
) != 16) {
2254 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 0) -> "
2255 "wcslen(destination)=%lu, expected 16\n", source
,
2256 wcslen(destination
));
2259 if (destination
[0] != L
'X') {
2260 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 0) -> "
2261 "destination[0]=%x, expected %x\n", source
, destination
[0],
2268 const wchar_t* source
= L
"";
2269 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
2270 size_t result
= wcslcpy(destination
, source
, 16);
2271 size_t expectedResult
= 0;
2272 if (result
!= expectedResult
) {
2273 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> result=%ld,"
2274 " expected %ld\n", source
, result
, expectedResult
);
2278 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> errno=%d, "
2279 "expected 0\n", source
, errno
);
2282 if (wcslen(destination
) != 0) {
2283 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2284 "wcslen(destination)=%lu, expected 0\n", source
,
2285 wcslen(destination
));
2288 if (destination
[0] != L
'\0') {
2289 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2290 "destination[0]=%x, expected %x\n", source
, destination
[0],
2294 if (destination
[1] != L
'X') {
2295 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2296 "destination[1]=%x, expected %x\n", source
, destination
[1],
2303 const wchar_t* source
= L
"test";
2304 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
2305 size_t result
= wcslcpy(destination
, source
, 3);
2306 size_t expectedResult
= 4;
2307 if (result
!= expectedResult
) {
2308 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 3) -> result=%ld, "
2309 "expected %ld\n", source
, result
, expectedResult
);
2313 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 3) -> errno=%d, "
2314 "expected 0\n", source
, errno
);
2317 if (wcslen(destination
) != 2) {
2318 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 2) -> "
2319 "wcslen(destination)=%lu, expected 3\n", source
,
2320 wcslen(destination
));
2323 if (destination
[0] != L
't') {
2324 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 3) -> "
2325 "destination[0]=%x, expected %x\n", source
, destination
[0],
2329 if (destination
[1] != L
'e') {
2330 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 3) -> "
2331 "destination[1]=%x, expected %x\n", source
, destination
[1],
2335 if (destination
[2] != L
'\0') {
2336 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 3) -> "
2337 "destination[2]=%x, expected %x\n", source
, destination
[2],
2341 if (destination
[3] != L
'X') {
2342 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 3) -> "
2343 "destination[3]=%x, expected %x\n", source
, destination
[3],
2350 const wchar_t* source
= L
"test";
2351 wchar_t destination
[] = L
"XXXXXXXXXXXXXXXX";
2352 size_t result
= wcslcpy(destination
, source
, 16);
2353 size_t expectedResult
= 4;
2354 if (result
!= expectedResult
) {
2355 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> result=%ld, "
2356 "expected %ld\n", source
, result
, expectedResult
);
2360 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> errno=%d, "
2361 "expected 0\n", source
, errno
);
2364 if (wcslen(destination
) != 4) {
2365 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2366 "wcslen(destination)=%lu, expected 4\n", source
,
2367 wcslen(destination
));
2370 if (destination
[0] != L
't') {
2371 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2372 "destination[0]=%x, expected %x\n", source
, destination
[0],
2376 if (destination
[1] != L
'e') {
2377 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2378 "destination[1]=%x, expected %x\n", source
, destination
[1],
2382 if (destination
[2] != L
's') {
2383 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2384 "destination[2]=%x, expected %x\n", source
, destination
[2],
2388 if (destination
[3] != L
't') {
2389 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2390 "destination[3]=%x, expected %x\n", source
, destination
[3],
2394 if (destination
[4] != L
'\0') {
2395 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2396 "destination[4]=%x, expected %x\n", source
, destination
[4],
2400 if (destination
[5] != L
'X') {
2401 printf("\tPROBLEM: wcslcpy(destination, \"%ls\", 16) -> "
2402 "destination[5]=%x, expected %x\n", source
, destination
[5],
2408 printf("\t%d problem(s) found!\n", problemCount
);
2410 printf("\tall fine\n");
2416 // #pragma mark - collation ----------------------------------------------------
2428 test_coll(bool useWcsxfrm
, const char* locale
, const coll_data coll
[])
2430 setlocale(LC_COLLATE
, locale
);
2431 printf("%s in %s locale\n", useWcsxfrm
? "wcsxfrm" : "wcscoll", locale
);
2433 int problemCount
= 0;
2434 for (unsigned int i
= 0; coll
[i
].a
!= NULL
; ++i
) {
2439 wchar_t sortKeyA
[100], sortKeyB
[100];
2440 wcsxfrm(sortKeyA
, coll
[i
].a
, 100);
2441 wcsxfrm(sortKeyB
, coll
[i
].b
, 100);
2442 result
= sign(wcscmp(sortKeyA
, sortKeyB
));
2443 sprintf(funcCall
, "wcscmp(wcsxfrm(\"%ls\"), wcsxfrm(\"%ls\"))",
2444 coll
[i
].a
, coll
[i
].b
);
2446 result
= sign(wcscoll(coll
[i
].a
, coll
[i
].b
));
2447 sprintf(funcCall
, "wcscoll(\"%ls\", \"%ls\")", coll
[i
].a
,
2451 if (result
!= coll
[i
].result
|| errno
!= coll
[i
].err
) {
2453 "\tPROBLEM: %s = %d (expected %d), errno = %x (expected %x)\n",
2454 funcCall
, result
, coll
[i
].result
, errno
, coll
[i
].err
);
2460 printf("\t%d problem(s) found!\n", problemCount
);
2462 printf("\tall fine\n");
2469 const coll_data coll_posix
[] = {
2471 { L
"test", L
"test", 0, 0 },
2472 { L
"tester", L
"test", 1, 0 },
2473 { L
"tEst", L
"teSt", -1, 0 },
2474 { L
"test", L
"tester", -1, 0 },
2475 { L
"tast", L
"t\xE4st", -1, EINVAL
},
2476 { L
"t\xE6st", L
"test", 1, EINVAL
},
2477 { NULL
, NULL
, 0, 0 }
2479 test_coll(0, "POSIX", coll_posix
);
2480 test_coll(1, "POSIX", coll_posix
);
2482 const coll_data coll_en
[] = {
2484 { L
"test", L
"test", 0, 0 },
2485 { L
"tester", L
"test", 1, 0 },
2486 { L
"tEst", L
"test", 1, 0 },
2487 { L
"test", L
"tester", -1, 0 },
2488 { L
"t\xE4st", L
"t\xE4st", 0, 0 },
2489 { L
"tast", L
"t\xE4st", -1, 0 },
2490 { L
"tbst", L
"t\xE4st", 1, 0 },
2491 { L
"tbst", L
"t\xE6st", 1, 0 },
2492 { L
"t\xE4st", L
"t\xC4st", -1, 0 },
2493 { L
"tBst", L
"t\xC4st", 1, 0 },
2494 { L
"tBst", L
"t\xE4st", 1, 0 },
2495 { L
"taest", L
"t\xE6st", -1, 0 },
2496 { L
"tafst", L
"t\xE6st", 1, 0 },
2497 { L
"taa", L
"t\xE4"L
"a", -1, 0 },
2498 { L
"tab", L
"t\xE4"L
"b", -1, 0 },
2499 { L
"tad", L
"t\xE4"L
"d", -1, 0 },
2500 { L
"tae", L
"t\xE4"L
"e", -1, 0 },
2501 { L
"taf", L
"t\xE4"L
"f", -1, 0 },
2502 { L
"cote", L
"cot\xE9", -1, 0 },
2503 { L
"cot\xE9", L
"c\xF4te", -1, 0 },
2504 { L
"c\xF4te", L
"c\xF4t\xE9", -1, 0 },
2505 { NULL
, NULL
, 0, 0 }
2507 test_coll(0, "en_US.UTF-8", coll_en
);
2508 test_coll(1, "en_US.UTF-8", coll_en
);
2510 const coll_data coll_de
[] = {
2512 { L
"test", L
"test", 0, 0 },
2513 { L
"tester", L
"test", 1, 0 },
2514 { L
"tEst", L
"test", 1, 0 },
2515 { L
"test", L
"tester", -1, 0 },
2516 { L
"t\xE4st", L
"t\xE4st", 0, 0 },
2517 { L
"tast", L
"t\xE4st", -1, 0 },
2518 { L
"tbst", L
"t\xE4st", 1, 0 },
2519 { L
"tbst", L
"t\xE6st", 1, 0 },
2520 { L
"t\xE4st", L
"t\xC4st", -1, 0 },
2521 { L
"tBst", L
"t\xC4st", 1, 0 },
2522 { L
"tBst", L
"t\xE4st", 1, 0 },
2523 { L
"taest", L
"t\xE6st", -1, 0 },
2524 { L
"tafst", L
"t\xE6st", 1, 0 },
2525 { L
"taa", L
"t\xE4", 1, 0 },
2526 { L
"tab", L
"t\xE4", 1, 0 },
2527 { L
"tad", L
"t\xE4", 1, 0 },
2528 { L
"tae", L
"t\xE4", 1, 0 },
2529 { L
"taf", L
"t\xE4", 1, 0 },
2530 { L
"cote", L
"cot\xE9", -1, 0 },
2531 { L
"cot\xE9", L
"c\xF4te", -1, 0 },
2532 { L
"c\xF4te", L
"c\xF4t\xE9", -1, 0 },
2533 { NULL
, NULL
, 0, 0 }
2535 test_coll(0, "de_DE.UTF-8", coll_de
);
2536 test_coll(1, "de_DE.UTF-8", coll_de
);
2538 const coll_data coll_de_phonebook
[] = {
2540 { L
"test", L
"test", 0, 0 },
2541 { L
"tester", L
"test", 1, 0 },
2542 { L
"tEst", L
"test", 1, 0 },
2543 { L
"test", L
"tester", -1, 0 },
2544 { L
"t\xE4st", L
"t\xE4st", 0, 0 },
2545 { L
"tast", L
"t\xE4st", 1, 0 },
2546 { L
"tbst", L
"t\xE4st", 1, 0 },
2547 { L
"tbst", L
"t\xE6st", 1, 0 },
2548 { L
"t\xE4st", L
"t\xC4st", -1, 0 },
2549 { L
"tBst", L
"t\xC4st", 1, 0 },
2550 { L
"tBst", L
"t\xE4st", 1, 0 },
2551 { L
"taest", L
"t\xE6st", -1, 0 },
2552 { L
"tafst", L
"t\xE6st", 1, 0 },
2553 { L
"taa", L
"t\xE4", -1, 0 },
2554 { L
"tab", L
"t\xE4", -1, 0 },
2555 { L
"tad", L
"t\xE4", -1, 0 },
2556 { L
"tae", L
"t\xE4", -1, 0 },
2557 { L
"taf", L
"t\xE4", 1, 0 },
2558 { L
"cote", L
"cot\xE9", -1, 0 },
2559 { L
"cot\xE9", L
"c\xF4te", -1, 0 },
2560 { L
"c\xF4te", L
"c\xF4t\xE9", -1, 0 },
2561 { NULL
, NULL
, 0, 0 }
2563 test_coll(0, "de_DE.UTF-8@collation=phonebook", coll_de_phonebook
);
2564 test_coll(1, "de_DE.UTF-8@collation=phonebook", coll_de_phonebook
);
2566 const coll_data coll_fr
[] = {
2568 { L
"test", L
"test", 0, 0 },
2569 { L
"tester", L
"test", 1, 0 },
2570 { L
"tEst", L
"test", 1, 0 },
2571 { L
"test", L
"tester", -1, 0 },
2572 { L
"t\xE4st", L
"t\xE4st", 0, 0 },
2573 { L
"tast", L
"t\xE4st", -1, 0 },
2574 { L
"tbst", L
"t\xE4st", 1, 0 },
2575 { L
"tbst", L
"t\xE6st", 1, 0 },
2576 { L
"t\xE4st", L
"t\xC4st", -1, 0 },
2577 { L
"tBst", L
"t\xC4st", 1, 0 },
2578 { L
"tBst", L
"t\xE4st", 1, 0 },
2579 { L
"taest", L
"t\xE6st", -1, 0 },
2580 { L
"tafst", L
"t\xE6st", 1, 0 },
2581 { L
"taa", L
"t\xE4", 1, 0 },
2582 { L
"tab", L
"t\xE4", 1, 0 },
2583 { L
"tad", L
"t\xE4", 1, 0 },
2584 { L
"tae", L
"t\xE4", 1, 0 },
2585 { L
"taf", L
"t\xE4", 1, 0 },
2586 { L
"cote", L
"cot\xE9", -1, 0 },
2587 { L
"cot\xE9", L
"c\xF4te", 1, 0 },
2588 { L
"c\xF4te", L
"c\xF4t\xE9", -1, 0 },
2589 { NULL
, NULL
, 0, 0 }
2591 // CLDR-1.9 has adjusted the defaults of fr_FR to no longer do reverse
2592 // ordering of secondary differences (accents), but fr_CA still does that
2594 test_coll(0, "fr_CA.UTF-8", coll_fr
);
2595 test_coll(1, "fr_CA.UTF-8", coll_fr
);
2599 // #pragma mark - wcsftime -----------------------------------------------------
2602 struct wcsftime_data
{
2603 const wchar_t* format
;
2604 const wchar_t* result
;
2609 test_wcsftime(const char* locale
, const wcsftime_data data
[])
2611 setlocale(LC_TIME
, locale
);
2612 setlocale(LC_CTYPE
, locale
);
2613 printf("wcsftime for '%s'\n", locale
);
2615 time_t nowSecs
= 1279391169; // pure magic
2616 tm
* now
= localtime(&nowSecs
);
2617 int problemCount
= 0;
2618 for (int i
= 0; data
[i
].format
!= NULL
; ++i
) {
2620 wcsftime(buf
, 100, data
[i
].format
, now
);
2621 if (wcscmp(buf
, data
[i
].result
) != 0) {
2623 "\tPROBLEM: wcsftime(\"%ls\") = \"%ls\" (expected \"%ls\")\n",
2624 data
[i
].format
, buf
, data
[i
].result
);
2629 printf("\t%d problem(s) found!\n", problemCount
);
2631 printf("\tall fine\n");
2638 setenv("TZ", "GMT", 1);
2640 const wcsftime_data wcsftime_posix
[] = {
2641 { L
"%c", L
"Sat Jul 17 18:26:09 2010" },
2642 { L
"%x", L
"07/17/10" },
2643 { L
"%X", L
"18:26:09" },
2645 { L
"%A", L
"Saturday" },
2650 test_wcsftime("POSIX", wcsftime_posix
);
2652 const wcsftime_data wcsftime_de
[] = {
2653 { L
"%c", L
"Samstag, 17. Juli 2010 18:26:09 GMT" },
2654 { L
"%x", L
"17.07.2010" },
2655 { L
"%X", L
"18:26:09" },
2657 { L
"%A", L
"Samstag" },
2662 test_wcsftime("de_DE.UTF-8", wcsftime_de
);
2664 const wcsftime_data wcsftime_hr
[] = {
2665 { L
"%c", L
"subota, 17. srpnja 2010. 18:26:09 GMT" },
2666 { L
"%x", L
"17. 07. 2010." },
2667 { L
"%X", L
"18:26:09" },
2669 { L
"%A", L
"subota" },
2671 { L
"%B", L
"srpnja" },
2674 test_wcsftime("hr_HR.ISO8859-2", wcsftime_hr
);
2676 const wcsftime_data wcsftime_gu
[] = {
2677 { L
"%c", L
"શનિવાર, 17 જુલાઈ, 2010 06:26:09 PM GMT" },
2678 { L
"%x", L
"17 જુલાઈ, 2010" },
2679 { L
"%X", L
"06:26:09 PM" },
2681 { L
"%A", L
"શનિવાર" },
2682 { L
"%b", L
"જુલાઈ" },
2683 { L
"%B", L
"જુલાઈ" },
2686 test_wcsftime("gu_IN", wcsftime_gu
);
2688 const wcsftime_data wcsftime_it
[] = {
2689 { L
"%c", L
"sabato 17 luglio 2010 18:26:09 GMT" },
2690 { L
"%x", L
"17/lug/2010" },
2691 { L
"%X", L
"18:26:09" },
2693 { L
"%A", L
"sabato" },
2695 { L
"%B", L
"luglio" },
2698 test_wcsftime("it_IT", wcsftime_it
);
2700 const wcsftime_data wcsftime_nl
[] = {
2701 { L
"%c", L
"zaterdag 17 juli 2010 18:26:09 GMT" },
2702 { L
"%x", L
"17 jul. 2010" },
2703 { L
"%X", L
"18:26:09" },
2705 { L
"%A", L
"zaterdag" },
2710 test_wcsftime("nl_NL", wcsftime_nl
);
2712 const wcsftime_data wcsftime_nb
[] = {
2713 { L
"%c", L
"kl. 18:26:09 GMT l\xF8rdag 17. juli 2010" },
2714 { L
"%x", L
"17. juli 2010" },
2715 { L
"%X", L
"18:26:09" },
2717 { L
"%A", L
"lørdag" },
2722 test_wcsftime("nb_NO", wcsftime_nb
);
2726 // #pragma mark - wcspbrk ------------------------------------------------------
2732 printf("wcspbrk()\n");
2734 int problemCount
= 0;
2738 const wchar_t* string
= L
"";
2739 const wchar_t* accept
= L
" ";
2740 const wchar_t* result
= wcspbrk(string
, accept
);
2741 const wchar_t* expected
= NULL
;
2742 if (result
!= expected
|| errno
!= 0) {
2743 printf("\tPROBLEM: result for wcspbrk(\"%ls\", \"%ls\") = %p "
2744 "(expected %p), errno = %x (expected 0)\n", string
, accept
,
2745 result
, expected
, errno
);
2751 const wchar_t* string
= L
"sometext";
2752 const wchar_t* accept
= L
" ";
2753 const wchar_t* result
= wcspbrk(string
, accept
);
2754 const wchar_t* expected
= NULL
;
2755 if (result
!= expected
|| errno
!= 0) {
2756 printf("\tPROBLEM: result for wcspbrk(\"%ls\", \"%ls\") = %p "
2757 "(expected %p), errno = %x (expected 0)\n", string
, accept
,
2758 result
, expected
, errno
);
2764 const wchar_t* string
= L
"some more text";
2765 const wchar_t* accept
= L
" ";
2766 const wchar_t* result
= wcspbrk(string
, accept
);
2767 const wchar_t* expected
= string
+ 4;
2768 if (result
!= expected
|| errno
!= 0) {
2769 printf("\tPROBLEM: result for wcspbrk(\"%ls\", \"%ls\") = %p "
2770 "(expected %p), errno = %x (expected 0)\n", string
, accept
,
2771 result
, expected
, errno
);
2777 const wchar_t* string
= L
"some more text";
2778 const wchar_t* accept
= L
"UY\xE4 ";
2779 const wchar_t* result
= wcspbrk(string
, accept
);
2780 const wchar_t* expected
= string
+ 4;
2781 if (result
!= expected
|| errno
!= 0) {
2782 printf("\tPROBLEM: result for wcspbrk(\"%ls\", \"%ls\") = %p "
2783 "(expected %p), errno = %x (expected 0)\n", string
, accept
,
2784 result
, expected
, errno
);
2790 const wchar_t* string
= L
"some more text";
2791 const wchar_t* accept
= L
" emorstx";
2792 const wchar_t* result
= wcspbrk(string
, accept
);
2793 const wchar_t* expected
= string
;
2794 if (result
!= expected
|| errno
!= 0) {
2795 printf("\tPROBLEM: result for wcspbrk(\"%ls\", \"%ls\") = %p "
2796 "(expected %p), errno = %x (expected 0)\n", string
, accept
,
2797 result
, expected
, errno
);
2803 const wchar_t* string
= L
"some more text";
2804 const wchar_t* accept
= L
"EMORSTX\xA0";
2805 const wchar_t* result
= wcspbrk(string
, accept
);
2806 const wchar_t* expected
= NULL
;
2807 if (result
!= expected
|| errno
!= 0) {
2808 printf("\tPROBLEM: result for wcspbrk(\"%ls\", \"%ls\") = %p "
2809 "(expected %p), errno = %x (expected 0)\n", string
, accept
,
2810 result
, expected
, errno
);
2816 printf("\t%d problem(s) found!\n", problemCount
);
2818 printf("\tall fine\n");
2822 // #pragma mark - wcscspn -------------------------------------------------------
2828 printf("wcscspn()\n");
2830 int problemCount
= 0;
2834 const wchar_t* string
= L
"";
2835 const wchar_t* reject
= L
" ";
2836 size_t result
= wcscspn(string
, reject
);
2837 size_t expected
= 0;
2838 if (result
!= expected
|| errno
!= 0) {
2839 printf("\tPROBLEM: result for wcscspn(\"%ls\", \"%ls\") = %ld "
2840 "(expected %ld), errno = %x (expected 0)\n", string
, reject
,
2841 result
, expected
, errno
);
2847 const wchar_t* string
= L
"sometext";
2848 const wchar_t* reject
= L
" ";
2849 size_t result
= wcscspn(string
, reject
);
2850 size_t expected
= 8;
2851 if (result
!= expected
|| errno
!= 0) {
2852 printf("\tPROBLEM: result for wcscspn(\"%ls\", \"%ls\") = %ld "
2853 "(expected %ld), errno = %x (expected 0)\n", string
, reject
,
2854 result
, expected
, errno
);
2860 const wchar_t* string
= L
"some more text";
2861 const wchar_t* reject
= L
" mos";
2862 size_t result
= wcscspn(string
, reject
);
2863 size_t expected
= 0;
2864 if (result
!= expected
|| errno
!= 0) {
2865 printf("\tPROBLEM: result for wcscspn(\"%ls\", \"%ls\") = %ld "
2866 "(expected %ld), errno = %x (expected 0)\n", string
, reject
,
2867 result
, expected
, errno
);
2873 const wchar_t* string
= L
"some more text";
2874 const wchar_t* reject
= L
"t";
2875 size_t result
= wcscspn(string
, reject
);
2876 size_t expected
= 10;
2877 if (result
!= expected
|| errno
!= 0) {
2878 printf("\tPROBLEM: result for wcscspn(\"%ls\", \"%ls\") = %ld "
2879 "(expected %ld), errno = %x (expected 0)\n", string
, reject
,
2880 result
, expected
, errno
);
2886 const wchar_t* string
= L
"some more text";
2887 const wchar_t* reject
= L
"abcdfghijklnpquvwyz\t";
2888 size_t result
= wcscspn(string
, reject
);
2889 size_t expected
= wcslen(string
);
2890 if (result
!= expected
|| errno
!= 0) {
2891 printf("\tPROBLEM: result for wcscspn(\"%ls\", \"%ls\") = %ld "
2892 "(expected %ld), errno = %x (expected 0)\n", string
, reject
,
2893 result
, expected
, errno
);
2899 const wchar_t* string
= L
"some more text";
2900 const wchar_t* reject
= L
"";
2901 size_t result
= wcscspn(string
, reject
);
2902 size_t expected
= wcslen(string
);
2903 if (result
!= expected
|| errno
!= 0) {
2904 printf("\tPROBLEM: result for wcscspn(\"%ls\", \"%ls\") = %ld "
2905 "(expected %ld), errno = %x (expected 0)\n", string
, reject
,
2906 result
, expected
, errno
);
2912 printf("\t%d problem(s) found!\n", problemCount
);
2914 printf("\tall fine\n");
2918 // #pragma mark - wcsspn -------------------------------------------------------
2924 printf("wcsspn()\n");
2926 int problemCount
= 0;
2930 const wchar_t* string
= L
"";
2931 const wchar_t* accept
= L
" ";
2932 size_t result
= wcsspn(string
, accept
);
2933 size_t expected
= 0;
2934 if (result
!= expected
|| errno
!= 0) {
2935 printf("\tPROBLEM: result for wcsspn(\"%ls\", \"%ls\") = %ld "
2936 "(expected %ld), errno = %x (expected 0)\n", string
, accept
,
2937 result
, expected
, errno
);
2943 const wchar_t* string
= L
"sometext";
2944 const wchar_t* accept
= L
" ";
2945 size_t result
= wcsspn(string
, accept
);
2946 size_t expected
= 0;
2947 if (result
!= expected
|| errno
!= 0) {
2948 printf("\tPROBLEM: result for wcsspn(\"%ls\", \"%ls\") = %ld "
2949 "(expected %ld), errno = %x (expected 0)\n", string
, accept
,
2950 result
, expected
, errno
);
2956 const wchar_t* string
= L
"some more text";
2957 const wchar_t* accept
= L
" emo";
2958 size_t result
= wcsspn(string
, accept
);
2959 size_t expected
= 0;
2960 if (result
!= expected
|| errno
!= 0) {
2961 printf("\tPROBLEM: result for wcsspn(\"%ls\", \"%ls\") = %ld "
2962 "(expected %ld), errno = %x (expected 0)\n", string
, accept
,
2963 result
, expected
, errno
);
2969 const wchar_t* string
= L
"some more text";
2970 const wchar_t* accept
= L
" emorstx";
2971 size_t result
= wcsspn(string
, accept
);
2972 size_t expected
= wcslen(string
);
2973 if (result
!= expected
|| errno
!= 0) {
2974 printf("\tPROBLEM: result for wcsspn(\"%ls\", \"%ls\") = %ld "
2975 "(expected %ld), errno = %x (expected 0)\n", string
, accept
,
2976 result
, expected
, errno
);
2982 const wchar_t* string
= L
"some more text";
2983 const wchar_t* accept
= L
"";
2984 size_t result
= wcsspn(string
, accept
);
2985 size_t expected
= 0;
2986 if (result
!= expected
|| errno
!= 0) {
2987 printf("\tPROBLEM: result for wcsspn(\"%ls\", \"%ls\") = %ld "
2988 "(expected %ld), errno = %x (expected 0)\n", string
, accept
,
2989 result
, expected
, errno
);
2995 printf("\t%d problem(s) found!\n", problemCount
);
2997 printf("\tall fine\n");
3001 // #pragma mark - wcsstr ------------------------------------------------------
3007 printf("wcsstr()\n");
3009 int problemCount
= 0;
3013 const wchar_t* string
= L
"";
3014 const wchar_t* sought
= L
" ";
3015 const wchar_t* result
= wcsstr(string
, sought
);
3016 const wchar_t* expected
= NULL
;
3017 if (result
!= expected
|| errno
!= 0) {
3018 printf("\tPROBLEM: result for wcsstr(\"%ls\", \"%ls\") = %p "
3019 "(expected %p), errno = %x (expected 0)\n", string
, sought
,
3020 result
, expected
, errno
);
3026 const wchar_t* string
= L
"sometext";
3027 const wchar_t* sought
= L
"som ";
3028 const wchar_t* result
= wcsstr(string
, sought
);
3029 const wchar_t* expected
= NULL
;
3030 if (result
!= expected
|| errno
!= 0) {
3031 printf("\tPROBLEM: result for wcsstr(\"%ls\", \"%ls\") = %p "
3032 "(expected %p), errno = %x (expected 0)\n", string
, sought
,
3033 result
, expected
, errno
);
3039 const wchar_t* string
= L
"sometext";
3040 const wchar_t* sought
= L
"soMe";
3041 const wchar_t* result
= wcsstr(string
, sought
);
3042 const wchar_t* expected
= NULL
;
3043 if (result
!= expected
|| errno
!= 0) {
3044 printf("\tPROBLEM: result for wcsstr(\"%ls\", \"%ls\") = %p "
3045 "(expected %p), errno = %x (expected 0)\n", string
, sought
,
3046 result
, expected
, errno
);
3052 const wchar_t* string
= L
"some more text";
3053 const wchar_t* sought
= L
"some ";
3054 const wchar_t* result
= wcsstr(string
, sought
);
3055 const wchar_t* expected
= string
;
3056 if (result
!= expected
|| errno
!= 0) {
3057 printf("\tPROBLEM: result for wcsstr(\"%ls\", \"%ls\") = %p "
3058 "(expected %p), errno = %x (expected 0)\n", string
, sought
,
3059 result
, expected
, errno
);
3065 const wchar_t* string
= L
"some more text";
3066 const wchar_t* sought
= L
" more";
3067 const wchar_t* result
= wcsstr(string
, sought
);
3068 const wchar_t* expected
= string
+ 4;
3069 if (result
!= expected
|| errno
!= 0) {
3070 printf("\tPROBLEM: result for wcsstr(\"%ls\", \"%ls\") = %p "
3071 "(expected %p), errno = %x (expected 0)\n", string
, sought
,
3072 result
, expected
, errno
);
3078 const wchar_t* string
= L
"some more text";
3079 const wchar_t* sought
= L
"some more text";
3080 const wchar_t* result
= wcsstr(string
, sought
);
3081 const wchar_t* expected
= string
;
3082 if (result
!= expected
|| errno
!= 0) {
3083 printf("\tPROBLEM: result for wcsstr(\"%ls\", \"%ls\") = %p "
3084 "(expected %p), errno = %x (expected 0)\n", string
, sought
,
3085 result
, expected
, errno
);
3091 const wchar_t* string
= L
"some more text";
3092 const wchar_t* sought
= L
"some more text ";
3093 const wchar_t* result
= wcsstr(string
, sought
);
3094 const wchar_t* expected
= NULL
;
3095 if (result
!= expected
|| errno
!= 0) {
3096 printf("\tPROBLEM: result for wcsstr(\"%ls\", \"%ls\") = %p "
3097 "(expected %p), errno = %x (expected 0)\n", string
, sought
,
3098 result
, expected
, errno
);
3104 printf("\t%d problem(s) found!\n", problemCount
);
3106 printf("\tall fine\n");
3110 // #pragma mark - wcstok ------------------------------------------------------
3116 printf("wcstok()\n");
3118 int problemCount
= 0;
3121 wchar_t string
[] = L
"";
3122 const wchar_t* delim
= L
" \t\n";
3124 wchar_t* result
= wcstok(string
, delim
, &state
);
3125 wchar_t* expected
= NULL
;
3126 wchar_t* expectedState
= NULL
;
3127 if (result
!= expected
|| state
!= expectedState
) {
3128 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3129 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3130 &state
, result
, expected
, state
, expectedState
);
3134 result
= wcstok(NULL
, delim
, &state
);
3136 expectedState
= NULL
;
3137 if (result
!= expected
|| state
!= expectedState
) {
3138 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3139 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3140 &state
, result
, expected
, state
, expectedState
);
3146 wchar_t string
[] = L
"\t\t\t\n \t";
3147 const wchar_t* delim
= L
" \t\n";
3149 wchar_t* result
= wcstok(string
, delim
, &state
);
3150 wchar_t* expected
= NULL
;
3151 wchar_t* expectedState
= NULL
;
3152 if (result
!= expected
|| state
!= expectedState
) {
3153 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3154 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3155 &state
, result
, expected
, state
, expectedState
);
3159 result
= wcstok(NULL
, delim
, &state
);
3161 expectedState
= NULL
;
3162 if (result
!= expected
|| state
!= expectedState
) {
3163 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3164 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3165 &state
, result
, expected
, state
, expectedState
);
3171 wchar_t string
[] = L
"just some text here!";
3172 const wchar_t* delim
= L
" ";
3174 wchar_t* result
= wcstok(string
, delim
, &state
);
3175 wchar_t* expected
= string
;
3176 wchar_t* expectedState
= string
+ 5;
3177 if (result
!= expected
|| state
!= expectedState
) {
3178 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3179 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3180 &state
, result
, expected
, state
, expectedState
);
3184 result
= wcstok(NULL
, delim
, &state
);
3185 expected
= string
+ 5;
3186 expectedState
= string
+ 10;
3187 if (result
!= expected
|| state
!= expectedState
) {
3188 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3189 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3190 &state
, result
, expected
, state
, expectedState
);
3194 result
= wcstok(NULL
, delim
, &state
);
3195 expected
= string
+ 10;
3196 expectedState
= string
+ 15;
3197 if (result
!= expected
|| state
!= expectedState
) {
3198 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3199 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3200 &state
, result
, expected
, state
, expectedState
);
3204 result
= wcstok(NULL
, delim
, &state
);
3205 expected
= string
+ 15;
3206 expectedState
= NULL
;
3207 if (result
!= expected
|| state
!= expectedState
) {
3208 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3209 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3210 &state
, result
, expected
, state
, expectedState
);
3214 result
= wcstok(NULL
, delim
, &state
);
3216 expectedState
= NULL
;
3217 if (result
!= expected
|| state
!= expectedState
) {
3218 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3219 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3220 &state
, result
, expected
, state
, expectedState
);
3226 wchar_t string
[] = L
" just \t\nsome\t\t\ttext\n\n\nhere!";
3227 const wchar_t* delim
= L
"\n\t ";
3229 wchar_t* result
= wcstok(string
, delim
, &state
);
3230 wchar_t* expected
= string
+ 1;
3231 wchar_t* expectedState
= string
+ 6;
3232 if (result
!= expected
|| state
!= expectedState
) {
3233 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3234 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3235 &state
, result
, expected
, state
, expectedState
);
3238 if (wcscmp(result
, L
"just") != 0) {
3239 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %ls "
3240 "(expected %ls)\n", string
, delim
, &state
, result
, L
"just");
3244 result
= wcstok(NULL
, delim
, &state
);
3245 expected
= string
+ 8;
3246 expectedState
= string
+ 13;
3247 if (result
!= expected
|| state
!= expectedState
) {
3248 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3249 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3250 &state
, result
, expected
, state
, expectedState
);
3253 if (wcscmp(result
, L
"some") != 0) {
3254 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %ls "
3255 "(expected %ls)\n", string
, delim
, &state
, result
, L
"some");
3259 result
= wcstok(NULL
, delim
, &state
);
3260 expected
= string
+ 15;
3261 expectedState
= string
+ 20;
3262 if (result
!= expected
|| state
!= expectedState
) {
3263 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3264 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3265 &state
, result
, expected
, state
, expectedState
);
3268 if (wcscmp(result
, L
"text") != 0) {
3269 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %ls "
3270 "(expected %ls)\n", string
, delim
, &state
, result
, L
"text");
3274 result
= wcstok(NULL
, delim
, &state
);
3275 expected
= string
+ 22;
3276 expectedState
= NULL
;
3277 if (result
!= expected
|| state
!= expectedState
) {
3278 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3279 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3280 &state
, result
, expected
, state
, expectedState
);
3283 if (wcscmp(result
, L
"here!") != 0) {
3284 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %ls "
3285 "(expected %ls)\n", string
, delim
, &state
, result
, L
"here!");
3289 result
= wcstok(NULL
, delim
, &state
);
3291 expectedState
= NULL
;
3292 if (result
!= expected
|| state
!= expectedState
) {
3293 printf("\tPROBLEM: result for wcstok(\"%ls\", \"%ls\", %p) = %p "
3294 "(expected %p), state = %p (expected %p)\n", string
, delim
,
3295 &state
, result
, expected
, state
, expectedState
);
3301 printf("\t%d problem(s) found!\n", problemCount
);
3303 printf("\tall fine\n");
3307 // #pragma mark - wmemchr ------------------------------------------------------
3313 printf("wmemchr()\n");
3315 int problemCount
= 0;
3319 const wchar_t* string
= L
"";
3320 const wchar_t ch
= L
' ';
3321 const wchar_t* result
= wmemchr(string
, ch
, 0);
3322 const wchar_t* expected
= NULL
;
3323 if (result
!= expected
|| errno
!= 0) {
3324 printf("\tPROBLEM: result for wmemchr(\"%ls\", '%lc', 0) = %p "
3325 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
3326 result
, expected
, errno
);
3332 const wchar_t* string
= L
"";
3333 const wchar_t ch
= L
'\0';
3334 const wchar_t* result
= wmemchr(string
, ch
, 0);
3335 const wchar_t* expected
= NULL
;
3336 if (result
!= expected
|| errno
!= 0) {
3337 printf("\tPROBLEM: result for wmemchr(\"%ls\", '%lc', 0) = %p "
3338 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
3339 result
, expected
, errno
);
3345 const wchar_t* string
= L
"";
3346 const wchar_t ch
= L
'\0';
3347 const wchar_t* result
= wmemchr(string
, ch
, 1);
3348 const wchar_t* expected
= string
;
3349 if (result
!= expected
|| errno
!= 0) {
3350 printf("\tPROBLEM: result for wmemchr(\"%ls\", '%lc', 1) = %p "
3351 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
3352 result
, expected
, errno
);
3358 const wchar_t* string
= L
"sometext";
3359 const wchar_t ch
= L
' ';
3360 const wchar_t* result
= wmemchr(string
, ch
, 8);
3361 const wchar_t* expected
= NULL
;
3362 if (result
!= expected
|| errno
!= 0) {
3363 printf("\tPROBLEM: result for wmemchr(\"%ls\", '%lc', 1) = %p "
3364 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
3365 result
, expected
, errno
);
3371 const wchar_t* string
= L
"some text";
3372 const wchar_t ch
= L
' ';
3373 const wchar_t* result
= wmemchr(string
, ch
, 9);
3374 const wchar_t* expected
= string
+ 4;
3375 if (result
!= expected
|| errno
!= 0) {
3376 printf("\tPROBLEM: result for wmemchr(\"%ls\", '%lc', 1) = %p "
3377 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
3378 result
, expected
, errno
);
3384 const wchar_t* string
= L
"some text";
3385 const wchar_t ch
= L
'M';
3386 const wchar_t* result
= wmemchr(string
, ch
, 9);
3387 const wchar_t* expected
= NULL
;
3388 if (result
!= expected
|| errno
!= 0) {
3389 printf("\tPROBLEM: result for wmemchr(\"%ls\", '%lc', 1) = %p "
3390 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
3391 result
, expected
, errno
);
3397 const wchar_t* string
= L
"some\0text";
3398 const wchar_t ch
= L
't';
3399 const wchar_t* result
= wmemchr(string
, ch
, 4);
3400 const wchar_t* expected
= NULL
;
3401 if (result
!= expected
|| errno
!= 0) {
3402 printf("\tPROBLEM: result for wmemchr(\"%ls\", '%lc', 1) = %p "
3403 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
3404 result
, expected
, errno
);
3410 const wchar_t* string
= L
"some\0text";
3411 const wchar_t ch
= L
't';
3412 const wchar_t* result
= wmemchr(string
, ch
, 9);
3413 const wchar_t* expected
= string
+ 5;
3414 if (result
!= expected
|| errno
!= 0) {
3415 printf("\tPROBLEM: result for wmemchr(\"%ls\", '%lc', 1) = %p "
3416 "(expected %p), errno = %x (expected 0)\n", string
, ch
,
3417 result
, expected
, errno
);
3423 printf("\t%d problem(s) found!\n", problemCount
);
3425 printf("\tall fine\n");
3429 // #pragma mark - wmemcmp ------------------------------------------------------
3435 printf("wmemcmp()\n");
3437 int problemCount
= 0;
3441 const wchar_t* a
= L
"";
3442 const wchar_t* b
= L
"";
3443 int result
= sign(wmemcmp(a
, b
, 0));
3445 if (result
!= expected
|| errno
!= 0) {
3446 printf("\tPROBLEM: result for wmemcmp(\"%ls\", \"%ls\", 0) = %d "
3447 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
3454 const wchar_t* a
= L
"";
3455 const wchar_t* b
= L
"";
3456 int result
= sign(wmemcmp(a
, b
, 1));
3458 if (result
!= expected
|| errno
!= 0) {
3459 printf("\tPROBLEM: result for wmemcmp(\"%ls\", \"%ls\", 0) = %d "
3460 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
3467 const wchar_t* a
= L
"a";
3468 const wchar_t* b
= L
"b";
3469 int result
= sign(wmemcmp(a
, b
, 0));
3471 if (result
!= expected
|| errno
!= 0) {
3472 printf("\tPROBLEM: result for wmemcmp(\"%ls\", \"%ls\", 0) = %d "
3473 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
3480 const wchar_t* a
= L
"a";
3481 const wchar_t* b
= L
"b";
3482 int result
= sign(wmemcmp(a
, b
, 1));
3484 if (result
!= expected
|| errno
!= 0) {
3485 printf("\tPROBLEM: result for wmemcmp(\"%ls\", \"%ls\", 1) = %d "
3486 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
3493 const wchar_t* a
= L
"b";
3494 const wchar_t* b
= L
"a";
3495 int result
= sign(wmemcmp(a
, b
, 2));
3497 if (result
!= expected
|| errno
!= 0) {
3498 printf("\tPROBLEM: result for wmemcmp(\"%ls\", \"%ls\", 2) = %d "
3499 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
3506 const wchar_t* a
= L
"a";
3507 const wchar_t* b
= L
"A";
3508 int result
= sign(wmemcmp(a
, b
, 2));
3510 if (result
!= expected
|| errno
!= 0) {
3511 printf("\tPROBLEM: result for wmemcmp(\"%ls\", \"%ls\", 2) = %d "
3512 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
3519 const wchar_t* a
= L
"täst";
3520 const wchar_t* b
= L
"täst";
3521 int result
= sign(wmemcmp(a
, b
, 5));
3523 if (result
!= expected
|| errno
!= 0) {
3524 printf("\tPROBLEM: result for wmemcmp(\"%ls\", \"%ls\", 5) = %d "
3525 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
3532 const wchar_t* a
= L
"täst";
3533 const wchar_t* b
= L
"täst ";
3534 int result
= sign(wmemcmp(a
, b
, 5));
3536 if (result
!= expected
|| errno
!= 0) {
3537 printf("\tPROBLEM: result for wmemcmp(\"%ls\", \"%ls\", 5) = %d "
3538 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
3545 const wchar_t* a
= L
"täSt";
3546 const wchar_t* b
= L
"täs";
3547 int result
= sign(wmemcmp(a
, b
, 2));
3549 if (result
!= expected
|| errno
!= 0) {
3550 printf("\tPROBLEM: result for wmemcmp(\"%ls\", \"%ls\", 2) = %d "
3551 "(expected %d), errno = %x (expected 0)\n", a
, b
, result
,
3558 printf("\t%d problem(s) found!\n", problemCount
);
3560 printf("\tall fine\n");
3564 // #pragma mark - wmemcpy ------------------------------------------------------
3570 printf("wmemcpy()\n");
3572 int problemCount
= 0;
3576 const wchar_t* source
= L
"";
3577 wchar_t destination
[] = L
"XXXX";
3578 wchar_t* result
= wmemcpy(destination
, source
, 0);
3579 if (result
!= destination
|| errno
!= 0) {
3580 printf("\tPROBLEM: result for wmemcpy(destination, \"%ls\", 0) = "
3581 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3582 result
, destination
, errno
);
3585 if (destination
[0] != L
'X') {
3586 printf("\tPROBLEM: wmemcpy(destination, \"%ls\", 0) -> "
3587 "destination[0]=%x, expected %x\n", source
, destination
[0],
3594 const wchar_t* source
= L
"";
3595 wchar_t destination
[] = L
"XXXX";
3596 wchar_t* result
= wmemcpy(destination
, source
, 1);
3597 if (result
!= destination
|| wmemcmp(destination
, source
, 1) != 0
3599 printf("\tPROBLEM: result for wmemcpy(destination, \"%ls\", 1) = "
3600 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3601 result
, destination
, errno
);
3604 if (destination
[1] != L
'X') {
3605 printf("\tPROBLEM: wmemcpy(destination, \"%ls\", 1) -> "
3606 "destination[1]=%x, expected %x\n", source
, destination
[1],
3613 const wchar_t* source
= L
"tÄstdata \0with some charäcters";
3614 wchar_t destination
[64];
3615 wchar_t* result
= wmemcpy(destination
, source
, 31);
3616 if (result
!= destination
|| wmemcmp(destination
, source
, 31) != 0
3618 printf("\tPROBLEM: result for wmemcpy(destination, \"%ls\", 31) = "
3619 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3620 result
, destination
, errno
);
3626 printf("\t%d problem(s) found!\n", problemCount
);
3628 printf("\tall fine\n");
3632 // #pragma mark - wmempcpy ------------------------------------------------------
3638 printf("wmempcpy()\n");
3640 int problemCount
= 0;
3644 const wchar_t* source
= L
"";
3645 wchar_t destination
[] = L
"XXXX";
3646 wchar_t* result
= wmempcpy(destination
, source
, 0);
3647 if (result
!= destination
|| errno
!= 0) {
3648 printf("\tPROBLEM: result for wmempcpy(destination, \"%ls\", 0) = "
3649 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3650 result
, destination
, errno
);
3653 if (destination
[0] != L
'X') {
3654 printf("\tPROBLEM: wmempcpy(destination, \"%ls\", 0) -> "
3655 "destination[0]=%x, expected %x\n", source
, destination
[0],
3662 const wchar_t* source
= L
"";
3663 wchar_t destination
[] = L
"XXXX";
3664 wchar_t* result
= wmempcpy(destination
, source
, 1);
3665 if (result
!= destination
+ 1 || wmemcmp(destination
, source
, 1) != 0
3667 printf("\tPROBLEM: result for wmempcpy(destination, \"%ls\", 1) = "
3668 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3669 result
, destination
, errno
);
3672 if (destination
[1] != L
'X') {
3673 printf("\tPROBLEM: wmempcpy(destination, \"%ls\", 1) -> "
3674 "destination[1]=%x, expected %x\n", source
, destination
[1],
3681 const wchar_t* source
= L
"tÄstdata \0with some charäcters";
3682 wchar_t destination
[64];
3683 wchar_t* result
= wmempcpy(destination
, source
, 31);
3684 if (result
!= destination
+ 31 || wmemcmp(destination
, source
, 31) != 0
3686 printf("\tPROBLEM: result for wmempcpy(destination, \"%ls\", 31) = "
3687 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3688 result
, destination
, errno
);
3694 printf("\t%d problem(s) found!\n", problemCount
);
3696 printf("\tall fine\n");
3700 // #pragma mark - wmemmove ------------------------------------------------------
3706 printf("wmemmove()\n");
3708 int problemCount
= 0;
3712 const wchar_t* source
= L
"";
3713 wchar_t destination
[] = L
"XXXX";
3714 wchar_t* result
= wmemmove(destination
, source
, 0);
3715 if (result
!= destination
|| errno
!= 0) {
3716 printf("\tPROBLEM: result for wmemmove(destination, \"%ls\", 0) = "
3717 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3718 result
, destination
, errno
);
3721 if (destination
[0] != L
'X') {
3722 printf("\tPROBLEM: wmemmove(destination, \"%ls\", 0) -> "
3723 "destination[0]=%x, expected %x\n", source
, destination
[0],
3730 const wchar_t* source
= L
"";
3731 wchar_t destination
[] = L
"XXXX";
3732 wchar_t* result
= wmemmove(destination
, source
, 1);
3733 if (result
!= destination
|| wmemcmp(destination
, source
, 1) != 0
3735 printf("\tPROBLEM: result for wmemmove(destination, \"%ls\", 1) = "
3736 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3737 result
, destination
, errno
);
3740 if (destination
[1] != L
'X') {
3741 printf("\tPROBLEM: wmemmove(destination, \"%ls\", 1) -> "
3742 "destination[1]=%x, expected %x\n", source
, destination
[1],
3749 const wchar_t* source
= L
"tÄstdata \0with some charäcters";
3750 wchar_t destination
[64];
3751 wmemcpy(destination
, source
, 31);
3752 wchar_t* result
= wmemmove(destination
, destination
+ 4, 27);
3753 if (result
!= destination
|| wmemcmp(destination
, source
+ 4, 27) != 0
3755 printf("\tPROBLEM: result for wmemmove(destination, \"%ls\", 27) = "
3756 "\"%ls\" (expected %p), errno = %x (expected 0)\n",
3757 source
+ 4, result
, destination
, errno
);
3763 const wchar_t* source
= L
"tÄstdata \0with some charäcters";
3764 wchar_t destination
[64];
3765 wmemcpy(destination
, source
, 31);
3766 wchar_t* result
= wmemmove(destination
+ 2, destination
, 8);
3767 if (result
!= destination
+ 2
3768 || wmemcmp(destination
, L
"tÄtÄstdatawith some charäcters", 31) != 0
3770 printf("\tPROBLEM: result for wmemmove(destination + 9, \"%ls\", 8)"
3771 " = \"%ls\" (expected %p), errno = %x (expected 0)\n",
3772 source
, result
, destination
, errno
);
3778 printf("\t%d problem(s) found!\n", problemCount
);
3780 printf("\tall fine\n");
3784 // #pragma mark - wmemset ------------------------------------------------------
3790 printf("wmemset()\n");
3792 int problemCount
= 0;
3796 wchar_t source
= L
'\0';
3797 wchar_t destination
[] = L
"XXXX";
3798 wchar_t* result
= wmemset(destination
, source
, 0);
3799 if (result
!= destination
|| errno
!= 0) {
3800 printf("\tPROBLEM: result for wmemset(destination, '%lc', 0) = "
3801 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3802 result
, destination
, errno
);
3805 if (destination
[0] != L
'X') {
3806 printf("\tPROBLEM: wmemset(destination, '%lc', 0) -> "
3807 "destination[0]=%x, expected %x\n", source
, destination
[0],
3814 wchar_t source
= L
'M';
3815 wchar_t destination
[] = L
"some text";
3816 wchar_t* result
= wmemset(destination
, source
, 1);
3817 if (result
!= destination
|| errno
!= 0) {
3818 printf("\tPROBLEM: result for wmemset(destination, '%lc', 1) = "
3819 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3820 result
, destination
, errno
);
3823 if (destination
[0] != L
'M') {
3824 printf("\tPROBLEM: wmemset(destination, '%lc', 1) -> "
3825 "destination[0]=%x, expected %x\n", source
, destination
[0],
3829 if (destination
[1] != L
'o') {
3830 printf("\tPROBLEM: wmemset(destination, '%lc', 1) -> "
3831 "destination[1]=%x, expected %x\n", source
, destination
[1],
3838 wchar_t source
= L
'M';
3839 wchar_t destination
[] = L
"some text";
3840 wchar_t* result
= wmemset(destination
, source
, 9);
3841 if (result
!= destination
|| errno
!= 0) {
3842 printf("\tPROBLEM: result for wmemset(destination, '%lc', 9) = "
3843 "\"%ls\" (expected %p), errno = %x (expected 0)\n", source
,
3844 result
, destination
, errno
);
3847 for (int i
= 0; i
< 9; ++i
) {
3848 if (destination
[i
] != L
'M') {
3849 printf("\tPROBLEM: wmemset(destination, '%lc', 9) -> "
3850 "destination[%d]=%x, expected %x\n", source
, i
,
3851 destination
[i
], L
'M');
3858 printf("\t%d problem(s) found!\n", problemCount
);
3860 printf("\tall fine\n");
3864 // #pragma mark - sprintf ------------------------------------------------------
3867 struct sprintf_data
{
3875 test_sprintf(const char* locale
, const sprintf_data data
[])
3877 setlocale(LC_ALL
, locale
);
3878 printf("sprintf for '%s'\n", locale
);
3880 int problemCount
= 0;
3881 for (int i
= 0; data
[i
].format
!= NULL
; ++i
) {
3883 if (strstr(data
[i
].format
, "%ls") != NULL
)
3884 sprintf(buf
, data
[i
].format
, (wchar_t*)data
[i
].value
);
3885 else if (strstr(data
[i
].format
, "%s") != NULL
)
3886 sprintf(buf
, data
[i
].format
, (char*)data
[i
].value
);
3887 if (strcmp(buf
, data
[i
].result
) != 0) {
3888 printf("\tPROBLEM: sprintf(\"%s\") = \"%s\" (expected \"%s\")\n",
3889 data
[i
].format
, buf
, data
[i
].result
);
3894 printf("\t%d problem(s) found!\n", problemCount
);
3896 printf("\tall fine\n");
3903 const sprintf_data sprintf_posix
[] = {
3904 { "%s", (const void*)"test", "test" },
3905 { "%ls", (const void*)L
"test", "test" },
3906 { NULL
, NULL
, NULL
}
3908 test_sprintf("POSIX", sprintf_posix
);
3910 const sprintf_data sprintf_de
[] = {
3911 { "%s", "test", "test" },
3912 { "%ls", L
"test", "test" },
3913 { "%s", "t\xC3\xA4st", "t\xC3\xA4st" },
3914 { "%ls", L
"t\xE4st", "t\xC3\xA4st" },
3915 { NULL
, NULL
, NULL
}
3917 test_sprintf("de_DE.UTF-8", sprintf_de
);
3919 const sprintf_data sprintf_de_iso
[] = {
3920 { "%s", "test", "test" },
3921 { "%ls", L
"test", "test" },
3922 { "%s", "t\xC3\xA4st", "t\xC3\xA4st" },
3923 { "%s", "t\xE4st", "t\xE4st" },
3924 { "%ls", L
"t\xE4st", "t\xE4st" },
3925 { NULL
, NULL
, NULL
}
3927 test_sprintf("de_DE.ISO8859-1", sprintf_de_iso
);
3931 // #pragma mark - swprintf ----------------------------------------------------
3934 struct swprintf_data
{
3935 const wchar_t* format
;
3937 const wchar_t* result
;
3942 test_swprintf(const char* locale
, const swprintf_data data
[])
3944 setlocale(LC_ALL
, locale
);
3945 printf("swprintf for '%s'\n", locale
);
3947 int problemCount
= 0;
3948 for (int i
= 0; data
[i
].format
!= NULL
; ++i
) {
3950 if (wcsstr(data
[i
].format
, L
"%ls") != NULL
)
3951 swprintf(buf
, 100, data
[i
].format
, (wchar_t*)data
[i
].value
);
3952 else if (wcsstr(data
[i
].format
, L
"%s") != NULL
)
3953 swprintf(buf
, 100, data
[i
].format
, (char*)data
[i
].value
);
3954 if (wcscmp(buf
, data
[i
].result
) != 0) {
3955 printf("\tPROBLEM: swprintf(\"%ls\") = \"%ls\" (expected \"%ls\")\n",
3956 data
[i
].format
, buf
, data
[i
].result
);
3961 printf("\t%d problem(s) found!\n", problemCount
);
3963 printf("\tall fine\n");
3970 const swprintf_data swprintf_posix
[] = {
3971 { L
"%s", (const void*)"test", L
"test" },
3972 { L
"%ls", (const void*)L
"test", L
"test" },
3973 { NULL
, NULL
, NULL
}
3975 test_swprintf("POSIX", swprintf_posix
);
3977 const swprintf_data swprintf_de
[] = {
3978 { L
"%s", "test", L
"test" },
3979 { L
"%ls", L
"test", L
"test" },
3980 { L
"%s", "t\xC3\xA4st", L
"t\xE4st" },
3981 { L
"%ls", L
"t\xE4st", L
"t\xE4st" },
3982 { NULL
, NULL
, NULL
}
3984 test_swprintf("de_DE.UTF-8", swprintf_de
);
3986 const swprintf_data swprintf_de_iso
[] = {
3987 { L
"%s", "test", L
"test" },
3988 { L
"%ls", L
"test", L
"test" },
3989 { L
"%s", "t\xC3\xA4st", L
"t\xC3\xA4st" },
3990 { L
"%s", "t\xE4st", L
"t\xE4st" },
3991 { L
"%ls", L
"t\xE4st", L
"t\xE4st" },
3992 { NULL
, NULL
, NULL
}
3994 test_swprintf("de_DE.ISO8859-1", swprintf_de_iso
);
3998 // #pragma mark - main ---------------------------------------------------------
4002 * Test several different aspects of the wchar-string functions.
4007 setlocale(LC_ALL
, "de_DE");