1#include <assert.h>2#include <stdio.h>3#include <wchar.h>45#define SIZ 667/*8output:9testing10test111test212test313done14end:15*/1617int18main()19{20 wchar_t *s, buf[SIZ];21 wchar_t abc[] = {'a', 'b', 'c'};2223 puts("testing");2425 puts("test1");26 wmemset(buf, '0', SIZ);27 s = wcsncpy(buf, abc, SIZ);28 assert(s == buf);29 assert(!wmemcmp(s, abc, SIZ));3031 puts("test2");32 wmemset(buf, '0', SIZ);33 s = wcsncpy(buf, (wchar_t[]) {0}, SIZ);34 assert(s == buf);35 assert(!wmemcmp(s, (wchar_t[SIZ]) {0}, SIZ));3637 puts("test3");38 wmemset(buf, '0', SIZ);39 s = wcsncpy(buf, (wchar_t[]) {0}, 1);40 assert(s == buf);41 assert(!wmemcmp(s,42 (wchar_t[SIZ]) {'\0', '0', '0', '0', '0', '0'},43 SIZ));4445 puts("done");4647 return 0;48}