x86: Move wcschr SSE2 implementation to multiarch/wcschr-sse2.S
[glibc.git] / string / test-ffs.c
blob94271294e187a68bc881af00ef0ee9f3f529a765
1 /* Copyright (C) 1994-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <string.h>
21 #include <support/check.h>
23 void try (const char *name, long long int param, int value, int expected)
25 if (value != expected)
27 printf ("%s(%#llx) expected %d got %d\n",
28 name, param, expected, value);
29 support_record_failure ();
31 else
32 printf ("%s(%#llx) as expected %d\n", name, param, value);
35 int
36 do_test (void)
38 int i;
40 #define TEST(fct, type) \
41 try (#fct, 0, fct ((type) 0), 0); \
42 for (i=0 ; i < 8 * sizeof (type); i++) \
43 try (#fct, 1ll << i, fct (((type) 1) << i), i + 1); \
44 for (i=0 ; i < 8 * sizeof (type) ; i++) \
45 try (#fct, (~((type) 0) >> i) << i, fct ((~((type) 0) >> i) << i), i + 1);\
46 try (#fct, 0x80008000, fct ((type) 0x80008000), 16)
48 TEST (ffs, int);
49 TEST (ffsl, long int);
50 TEST (ffsll, long long int);
52 return 0;
55 #include <support/test-driver.c>