]> git.ipfire.org Git - thirdparty/glibc.git/blame - wcsmbs/tst-wcpncpy.c
dlfcn: Remove remnants of caller sensitivity from dlinfo
[thirdparty/glibc.git] / wcsmbs / tst-wcpncpy.c
CommitLineData
04277e02 1/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
bc55a0b8
UD
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>, 2003.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
bc55a0b8 18
818ef36c 19#include <stdio.h>
bc55a0b8
UD
20#include <wchar.h>
21
22
29955b5d
AS
23static int
24do_test (void)
bc55a0b8 25{
818ef36c
UD
26 int result = 0;
27
bc55a0b8 28 const wchar_t src[] = L"0";
d4b60383 29 wchar_t dest[21];
bc55a0b8 30 wmemset (dest, L'\0', 10);
818ef36c
UD
31 wchar_t *endp = wcpncpy (dest, src, 2);
32 if (wcscmp (dest, src) != 0)
33 {
34 result = 1;
35 puts ("L\"0\" string test failed");
36 }
37 if (endp != dest + 1)
38 {
39 result = 1;
40 puts ("return value of L\"0\" string call incorrect");
41 }
42
43 const wchar_t src2[] = L"abc";
44 endp = wcpncpy (dest, src2, 2);
45 if (endp != dest + 2)
46 {
47 result = 1;
48 puts ("return value of limited call incorrect");
49 }
50
51 const wchar_t src3[] = L"";
52 endp = wcpncpy (dest, src3, 2);
53 if (endp != dest)
54 {
55 result = 1;
56 puts ("return value of empty string call incorrect");
57 }
58
59 const wchar_t src4[] = L"abcdefghijklmnopqrstuvwxyz";
60 endp = wcpncpy (dest, src4, 2);
61 if (endp != dest + 2)
62 {
63 result = 1;
64 puts ("return value of long string call incorrect");
65 }
66
d4b60383
UD
67 const wchar_t src5[] = L"ab";
68 endp = wcpncpy (dest, src5, 20);
69 if (endp != dest + 2)
70 {
71 result = 1;
72 puts ("return value of large limit call incorrect");
73 }
74
818ef36c 75 return result;
bc55a0b8 76}
29955b5d 77
b2b1ea8b 78#include <support/test-driver.c>