|
8 | 8 |
|
9 | 9 | #include "test/UnitTest/Test.h"
|
10 | 10 |
|
11 |
| -#include "llvm-libc-macros/stdbit-macros.h" |
12 |
| -#include "src/__support/CPP/limits.h" // UINT_WIDTH |
13 |
| -#include "src/stdbit/stdc_leading_zeros_uc.h" |
14 |
| -#include "src/stdbit/stdc_leading_zeros_ui.h" |
15 |
| -#include "src/stdbit/stdc_leading_zeros_ul.h" |
16 |
| -#include "src/stdbit/stdc_leading_zeros_ull.h" |
17 |
| -#include "src/stdbit/stdc_leading_zeros_us.h" |
| 11 | +#include <stdbit.h> |
| 12 | + |
| 13 | +/* |
| 14 | + * The intent of this test is validate that: |
| 15 | + * 1. We provide the definition of the various type generic macros of stdbit.h. |
| 16 | + * 2. It dispatches to the correct underlying function. |
| 17 | + * Because unit tests build without public packaging, the object files produced |
| 18 | + * do not contain non-namespaced symbols. |
| 19 | + */ |
| 20 | + |
| 21 | +unsigned char stdc_leading_zeros_uc(unsigned char) { return 0xAA; } |
| 22 | +unsigned short stdc_leading_zeros_us(unsigned short) { return 0xAB; } |
| 23 | +unsigned stdc_leading_zeros_ui(unsigned) { return 0xAC; } |
| 24 | +unsigned long stdc_leading_zeros_ul(unsigned long) { return 0xAD; } |
| 25 | +unsigned long long stdc_leading_zeros_ull(unsigned long long) { return 0xAF; } |
18 | 26 |
|
19 | 27 | TEST(LlvmLibcStdbitTest, TypeGenericMacro) {
|
20 |
| - using namespace LIBC_NAMESPACE; |
21 |
| - EXPECT_EQ(stdc_leading_zeros(0U), static_cast<unsigned>(UINT_WIDTH)); |
| 28 | + EXPECT_EQ(stdc_leading_zeros(static_cast<unsigned char>(0U)), static_cast<unsigned char>(0xAA)); |
| 29 | + EXPECT_EQ(stdc_leading_zeros(static_cast<unsigned short>(0U)), |
| 30 | + static_cast<unsigned short>(0xAB)); |
| 31 | + EXPECT_EQ(stdc_leading_zeros(0U), static_cast<unsigned>(0xAC)); |
| 32 | + EXPECT_EQ(stdc_leading_zeros(0UL), static_cast<unsigned long>(0xAD)); |
| 33 | + EXPECT_EQ(stdc_leading_zeros(0ULL), static_cast<unsigned long long>(0xAF)); |
22 | 34 | }
|
0 commit comments