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-06-12 09:48:57 +0300
committerkcgen <kcgen@users.noreply.github.com>2022-06-12 09:48:57 +0300
commit74be117ae9d24f8b96bf4af125a1fc9613abd51f (patch)
tree83fa43127d5d646da7a3654ae5d69d2778c5dde6 /tests
parent428763fcd6637ac4734d05ead34d062bacd5dfd7 (diff)
Use a trivial copy constructor in bit_view
Diffstat (limited to 'tests')
-rw-r--r--tests/bit_view_tests.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/bit_view_tests.cpp b/tests/bit_view_tests.cpp
index 25e9620a8..4d9a0579d 100644
--- a/tests/bit_view_tests.cpp
+++ b/tests/bit_view_tests.cpp
@@ -32,6 +32,19 @@ union Register {
bit_view<5, 3> last_3; // is bits 5, 6, and 7
};
+// function to take in and return a Register by value
+Register pass_by_value(const Register in)
+{
+ // empty register
+ Register out = {0};
+
+ // assign just the middle_3
+ out.middle_3 = in.middle_3;
+
+ // return by value
+ return out;
+}
+
// function to take in a reference of a Register and set its bits
void set_bits(Register &reg, uint8_t first, uint8_t middle, uint8_t last)
{
@@ -297,6 +310,22 @@ TEST(bit_view, illegal_view)
};
}
+TEST(bit_view, pass_by_value)
+{
+ const Register in = {0b111'010'11};
+
+ // The function assigns and returns just the middle_3 from 'in'
+ const auto out = pass_by_value(in);
+
+ // should only have middle_3 set from in
+ EXPECT_EQ(out.middle_3, in.middle_3);
+ EXPECT_EQ(out.middle_3, 0b010);
+
+ // first_2 and last_3 should still be zeros
+ EXPECT_EQ(out.first_2, 0b00);
+ EXPECT_EQ(out.last_3, 0b000);
+}
+
TEST(bit_view, writable_via_reference)
{
// create a register and set it bits using the "set_bits" function