Skip to content

Commit

Permalink
util/tests: add set bit range test
Browse files Browse the repository at this point in the history
This simple test validates that it is possible to set bits
across word bounary.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11321>
  • Loading branch information
austriancoder authored and Marge Bot committed Sep 21, 2021
1 parent b3b03e3 commit 54ea23d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/util/bitset_test.cpp
Expand Up @@ -381,3 +381,23 @@ TEST(bitset, test_shl_two_words)
EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false);
EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), true);
}

TEST(bitset, test_setrange_across_word_boundary)
{
BITSET_DECLARE(r, 128);
BITSET_ZERO(r);

BITSET_SET_RANGE(r, 62, 65);

EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false);
EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), true);
EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), true);
EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false);

EXPECT_EQ(BITSET_TEST(r, 61), false);

for (int i = 62; i <= 65; i++)
EXPECT_EQ(BITSET_TEST(r, i), true);

EXPECT_EQ(BITSET_TEST(r, 66), false);
}

0 comments on commit 54ea23d

Please sign in to comment.