diff options
| author | Nick Desaulniers <nickdesaulniers@users.noreply.github.com> | 2024-02-26 09:25:24 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-26 09:25:24 -0800 |
| commit | d8406d48a8c94f88613e5613a7e0d6526a520428 (patch) | |
| tree | 443501f9a301f383dd73be14007d599a66b7b3c8 /libc/test/src/stdbit/stdc_count_ones_ull_test.cpp | |
| parent | be024307075c37f057fd51d4de0e9c2443b51686 (diff) | |
[libc][stdbit] implement stdc_count_ones (C23) (#82444)
Diffstat (limited to 'libc/test/src/stdbit/stdc_count_ones_ull_test.cpp')
| -rw-r--r-- | libc/test/src/stdbit/stdc_count_ones_ull_test.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libc/test/src/stdbit/stdc_count_ones_ull_test.cpp b/libc/test/src/stdbit/stdc_count_ones_ull_test.cpp new file mode 100644 index 000000000000..a0e69459c5a8 --- /dev/null +++ b/libc/test/src/stdbit/stdc_count_ones_ull_test.cpp @@ -0,0 +1,21 @@ +//===-- Unittests for stdc_count_ones_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_count_ones_ull.h" +#include "test/UnitTest/Test.h" + +TEST(LlvmLibcStdcCountOnesUllTest, Zero) { + EXPECT_EQ(LIBC_NAMESPACE::stdc_count_ones_ull(0ULL), 0U); +} + +TEST(LlvmLibcStdcCountOnesUllTest, Ones) { + for (unsigned i = 0U; i != ULLONG_WIDTH; ++i) + EXPECT_EQ(LIBC_NAMESPACE::stdc_count_ones_ull(ULLONG_MAX >> i), + ULLONG_WIDTH - i); +} |
