Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorkcgen <kcgen@users.noreply.github.com>2022-08-23 06:48:29 +0300
committerkcgen <1557255+kcgen@users.noreply.github.com>2022-08-25 20:13:26 +0300
commit5d5d3c3ca0e6e879f6a276850da3c6de3242cf97 (patch)
tree8c4bb6e412641ce69640d4b484284518c439f007 /tests
parent907723b253d9a010a0fbeb3d2e9657b50f1a86e8 (diff)
Add a bit-retention function, retain(), to bitops
Diffstat (limited to 'tests')
-rw-r--r--tests/bitops_tests.cpp14
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)
{