]> git.ipfire.org Git - thirdparty/glibc.git/blob - stdlib/tst-stdc_first_leading_zero.c
stdlib: Verify heapsort for two-element cases
[thirdparty/glibc.git] / stdlib / tst-stdc_first_leading_zero.c
1 /* Test stdc_first_leading_zero functions and macros.
2 Copyright (C) 2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19 #include <tst-stdbit.h>
20
21 static const struct stdbit_test inputs[] =
22 {
23 { 0ULL, 1, 1, 1, 1 },
24 { 0x1ULL, 1, 1, 1, 1 },
25 { 0x2ULL, 1, 1, 1, 1 },
26 { 0x3ULL, 1, 1, 1, 1 },
27 { 0x4ULL, 1, 1, 1, 1 },
28 { 0x5ULL, 1, 1, 1, 1 },
29 { 0x6ULL, 1, 1, 1, 1 },
30 { 0x7ULL, 1, 1, 1, 1 },
31 { 0x8ULL, 1, 1, 1, 1 },
32 { 0x9ULL, 1, 1, 1, 1 },
33 { 0xaULL, 1, 1, 1, 1 },
34 { 0xbULL, 1, 1, 1, 1 },
35 { 0xcULL, 1, 1, 1, 1 },
36 { 0xdULL, 1, 1, 1, 1 },
37 { 0xeULL, 1, 1, 1, 1 },
38 { 0xfULL, 1, 1, 1, 1 },
39 { 0x10ULL, 1, 1, 1, 1 },
40 { 0x11ULL, 1, 1, 1, 1 },
41 { 0x12ULL, 1, 1, 1, 1 },
42 { 0x1fULL, 1, 1, 1, 1 },
43 { 0x20ULL, 1, 1, 1, 1 },
44 { 0x7fULL, 1, 1, 1, 1 },
45 { 0x80ULL, 2, 1, 1, 1 },
46 { 0x81ULL, 2, 1, 1, 1 },
47 { 0x9aULL, 2, 1, 1, 1 },
48 { 0xf3ULL, 5, 1, 1, 1 },
49 { 0xffULL, 0, 1, 1, 1 },
50 { 0x100ULL, 1, 1, 1, 1 },
51 { 0x101ULL, 1, 1, 1, 1 },
52 { 0x102ULL, 1, 1, 1, 1 },
53 { 0x1feULL, 8, 1, 1, 1 },
54 { 0x1ffULL, 0, 1, 1, 1 },
55 { 0x200ULL, 1, 1, 1, 1 },
56 { 0x234ULL, 1, 1, 1, 1 },
57 { 0x4567ULL, 1, 1, 1, 1 },
58 { 0x7fffULL, 0, 1, 1, 1 },
59 { 0x8000ULL, 1, 2, 1, 1 },
60 { 0x8001ULL, 1, 2, 1, 1 },
61 { 0xfffeULL, 8, 16, 1, 1 },
62 { 0xffffULL, 0, 0, 1, 1 },
63 { 0x10000ULL, 1, 1, 1, 1 },
64 { 0x10001ULL, 1, 1, 1, 1 },
65 { 0xfedcba98ULL, 2, 2, 8, 1 },
66 { 0xfffffefeULL, 8, 8, 24, 1 },
67 { 0xffffffffULL, 0, 0, 0, 1 },
68 { 0x100000000ULL, 1, 1, 1, 1 },
69 { 0x100000001ULL, 1, 1, 1, 1 },
70 { 0x123456789ULL, 2, 1, 1, 1 },
71 { 0x123456789abcdefULL, 4, 3, 2, 1 },
72 { 0x789abcdef0123456ULL, 1, 1, 5, 1 },
73 { 0x8000000000000000ULL, 1, 1, 1, 2 },
74 { 0x8000000000000001ULL, 1, 1, 1, 2 },
75 { 0xfffffffffffffffeULL, 8, 16, 32, 64 },
76 { 0xffffffffffffffffULL, 0, 0, 0, 0 },
77 };
78
79 TEST_STDBIT_UI_TOPLEVEL (stdc_first_leading_zero);
80
81 static int
82 do_test (void)
83 {
84 TEST_STDBIT_UI (stdc_first_leading_zero, inputs);
85 return 0;
86 }
87
88 #include <support/test-driver.c>