2 Copyright (C) 2001-2023 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. */
21 #undef __GLIBC_USE_DEPRECATED_GETS
22 #define __GLIBC_USE_DEPRECATED_GETS 1
34 if (gets (buf
) != buf
)
36 printf ("gets: read error: %m\n");
39 else if (strchr (buf
, '\n') != NULL
)
41 printf ("newline not stripped: \"%s\"\n", buf
);
44 else if (strcmp (buf
, "foo") != 0)
46 printf ("read mismatch: expected \"%s\", got \"%s\"\n", "foo", buf
);
50 if (gets (buf
) != buf
)
52 printf ("gets: read error: %m\n");
55 else if (strchr (buf
, '\n') != NULL
)
57 printf ("newline not stripped: \"%s\"\n", buf
);
60 else if (strcmp (buf
, "bar") != 0)
62 printf ("read mismatch: expected \"%s\", got \"%s\"\n", "bar", buf
);
69 #define TEST_FUNCTION do_test ()
70 #include "../test-skeleton.c"