x86_64: Fix missing wcsncat function definition without multiarch (x86-64-v4)
[glibc.git] / stdio-common / tst-gets.c
blob7feb4bd09dd552f3ada9565509ba789ae9befaec
1 /* Tests for gets.
2 Copyright (C) 2001-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 /* This file tests gets. Force it to be declared. */
20 #include <features.h>
21 #undef __GLIBC_USE_DEPRECATED_GETS
22 #define __GLIBC_USE_DEPRECATED_GETS 1
24 #include <stdio.h>
25 #include <string.h>
28 static int
29 do_test (void)
31 char buf[100];
32 int result = 0;
34 if (gets (buf) != buf)
36 printf ("gets: read error: %m\n");
37 result = 1;
39 else if (strchr (buf, '\n') != NULL)
41 printf ("newline not stripped: \"%s\"\n", buf);
42 result = 1;
44 else if (strcmp (buf, "foo") != 0)
46 printf ("read mismatch: expected \"%s\", got \"%s\"\n", "foo", buf);
47 result = 1;
50 if (gets (buf) != buf)
52 printf ("gets: read error: %m\n");
53 result = 1;
55 else if (strchr (buf, '\n') != NULL)
57 printf ("newline not stripped: \"%s\"\n", buf);
58 result = 1;
60 else if (strcmp (buf, "bar") != 0)
62 printf ("read mismatch: expected \"%s\", got \"%s\"\n", "bar", buf);
63 result = 1;
66 return result;
69 #define TEST_FUNCTION do_test ()
70 #include "../test-skeleton.c"