diff options
author | kcgen <kcgen@users.noreply.github.com> | 2022-08-23 06:48:29 +0300 |
---|---|---|
committer | kcgen <1557255+kcgen@users.noreply.github.com> | 2022-08-25 20:13:26 +0300 |
commit | 5d5d3c3ca0e6e879f6a276850da3c6de3242cf97 (patch) | |
tree | 8c4bb6e412641ce69640d4b484284518c439f007 /tests | |
parent | 907723b253d9a010a0fbeb3d2e9657b50f1a86e8 (diff) |
Add a bit-retention function, retain(), to bitops
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bitops_tests.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/bitops_tests.cpp b/tests/bitops_tests.cpp index 2aa422860..d3535b33d 100644 --- a/tests/bitops_tests.cpp +++ b/tests/bitops_tests.cpp @@ -279,6 +279,20 @@ TEST(bitops, bits_not_too_wide_for_dword) EXPECT_TRUE(bit::is(reg, b8 | b24 | b31)); } +// Retain operations +TEST(bitops, retain) +{ + // Retain a positive bit, with surrounding other bits + uint8_t reg = (b0 | b1 | b2); + bit::retain(reg, b1); + EXPECT_EQ(reg, b1); + + // Retain a negative bit, with surrounding other bits + reg = (b0 | b1 | b2 | b3 /*| b4*/ | b5 | b6 | b7); + bit::retain(reg, b4); + EXPECT_EQ(reg, 0); +} + // Masking operations TEST(bitops, masking) { |