| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,112 +1,22 @@ | ||
| add_custom_target(libc-stdbit-tests) | ||
|
|
||
| set(prefixes | ||
| leading_zeros | ||
| leading_ones | ||
| trailing_zeros | ||
| ) | ||
| set(suffixes c s i l ll) | ||
| foreach(prefix IN LISTS prefixes) | ||
| foreach(suffix IN LISTS suffixes) | ||
| add_libc_test( | ||
| stdc_${prefix}_u${suffix}_test | ||
| SUITE | ||
| libc-stdbit-tests | ||
| SRCS | ||
| stdc_${prefix}_u${suffix}_test.cpp | ||
| DEPENDS | ||
| libc.src.__support.CPP.limits | ||
| libc.src.stdbit.stdc_${prefix}_u${suffix} | ||
| ) | ||
| endforeach() | ||
| endforeach() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_zeros_uc ------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_zeros_uc.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUcTest, Zero) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_uc(0U), | ||
| static_cast<unsigned>(UCHAR_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUcTest, OneHot) { | ||
| for (unsigned i = 0U; i != UCHAR_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_uc(1U << i), i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_zeros_ui ------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_zeros_ui.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUiTest, Zero) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_ui(0U), | ||
| static_cast<unsigned>(UINT_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUiTest, OneHot) { | ||
| for (unsigned i = 0U; i != UINT_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_ui(1U << i), i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_zeros_ul ------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_zeros_ul.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUlTest, Zero) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_ul(0U), | ||
| static_cast<unsigned>(ULONG_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUlTest, OneHot) { | ||
| for (unsigned i = 0U; i != ULONG_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_ul(1UL << i), i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_zeros_ull -----------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_zeros_ull.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUllTest, Zero) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_ull(0U), | ||
| static_cast<unsigned>(ULLONG_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUllTest, OneHot) { | ||
| for (unsigned i = 0U; i != ULLONG_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_ull(1ULL << i), i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //===-- Unittests for stdc_trailing_zeros_us ------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "src/__support/CPP/limits.h" | ||
| #include "src/stdbit/stdc_trailing_zeros_us.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUsTest, Zero) { | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_us(0U), | ||
| static_cast<unsigned>(USHRT_WIDTH)); | ||
| } | ||
|
|
||
| TEST(LlvmLibcStdcTrailingZerosUsTest, OneHot) { | ||
| for (unsigned i = 0U; i != USHRT_WIDTH; ++i) | ||
| EXPECT_EQ(LIBC_NAMESPACE::stdc_trailing_zeros_us(1U << i), i); | ||
| } |