gdbserver_tests: filter out new Missing rpms message
[valgrind.git] / memcheck / tests / wcpncpy.c
blob97d1a13bb849792d991ff70f1a1329de31263ac2
1 #include <wchar.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <assert.h>
6 int main(void)
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));
13 // uninit read
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);
32 // overlap
33 // sss
34 // ddd
35 wcpncpy(dest2, dest2+2, 3);
37 wcpncpy(dest2, in, 5);
38 wcpncpy(dest2+5, in, 6);
40 // overlap
41 // sss
42 // ddd
43 wcpncpy(dest2+2, dest2, 3);
45 free(dest1);
46 free(dest2);