inet_pton tests, fix regression test case
[libc-test.git] / src / regression / mbsrtowcs-overflow.c
blob6f2a9da073305f4c5c227ea163841838d7dfe97e
1 // commit 211264e46a2f1bc382a84435e904d1548de672b0 2013-09-27
2 // mbsrtowcs should not write outside the ws array
3 #include <wchar.h>
4 #include "test.h"
6 int main(void)
8 wchar_t ws[] = L"XXXXX";
9 const char *src = "abcd";
10 const char *want = src + 4;
11 size_t r;
13 r = mbsrtowcs(ws, &src, 4, 0);
14 if (r != 4)
15 t_error("mbsrtowcs(ws, &abcd, 4, 0) returned %zu, wanted 4\n", r);
16 if (src != want)
17 t_error("mbsrtowcs(ws, &abcd, 4, 0) set abcd to %p wanted %p\n", src, want);
18 if (wcscmp(ws, L"abcdX") != 0)
19 t_error("ws is L\"%ls\", wanted L\"abcdX\"\n", ws);
21 return t_status;