Skip to content

Commit 39c0256

Browse files
committed
Fix test that was still shifting by the wrong amount
1 parent 22c269c commit 39c0256

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

libc/test/src/__support/big_int_test.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,9 @@ TYPED_TEST(LlvmLibcUIntClassTest, Masks, Types) {
192192

193193
TYPED_TEST(LlvmLibcUIntClassTest, CountBits, Types) {
194194
if constexpr (!T::SIGNED) {
195-
for (size_t i = 0; i <= T::BITS; ++i) {
196-
const auto zero_or = [i](T value) {
197-
// Prevent UB when i == T::BITS.
198-
return i == T::BITS ? 0 : value;
199-
};
200-
const auto l_one = zero_or(T::all_ones() << i); // 0b111...000
201-
const auto r_one = zero_or(T::all_ones() >> i); // 0b000...111
195+
for (size_t i = 0; i < T::BITS; ++i) {
196+
const auto l_one = T::all_ones() << i; // 0b111...000
197+
const auto r_one = T::all_ones() >> i; // 0b000...111
202198
const int zeros = i;
203199
const int ones = T::BITS - zeros;
204200
ASSERT_EQ(cpp::countr_one(r_one), ones);

0 commit comments

Comments
 (0)