8 const wchar_t in
[] = {L
'H', L
'e', L
'l', L
'l', L
'o', 0};
10 wchar_t* dest1
= malloc(5*sizeof(wchar_t) + 2);
11 wchar_t* dest2
= malloc(11*sizeof(wchar_t));
14 wcpncpy(dest1
, dest2
, 3);
16 wchar_t* end
= wcpncpy(dest1
, in
, 3);
18 assert(3 == end
- dest1
);
19 assert(0 == wmemcmp(in
, dest1
, 3));
21 end
= wcpncpy(dest2
, in
, 10);
22 assert(5 == end
- dest2
);
23 assert(0 == wmemcmp(dest2
, in
, 6));
24 assert(0 == dest2
[9]);
26 // too small - invalid write
27 end
= wcpncpy(dest1
, in
, 6);
29 wcpncpy(dest2
, in
, 5);
30 wcpncpy(dest2
+5, in
, 6);
35 wcpncpy(dest2
, dest2
+2, 3);
37 wcpncpy(dest2
, in
, 5);
38 wcpncpy(dest2
+5, in
, 6);
43 wcpncpy(dest2
+2, dest2
, 3);