aboutsummaryrefslogtreecommitdiffstats
path: root/tests/byte_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/byte_tests.cpp')
-rw-r--r--tests/byte_tests.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/byte_tests.cpp b/tests/byte_tests.cpp
index 3bbf382..8cb0da8 100644
--- a/tests/byte_tests.cpp
+++ b/tests/byte_tests.cpp
@@ -43,7 +43,7 @@ SUITE(byte_tests)
byte b = byte(12);
CHECK(static_cast<unsigned char>(b) == 12);
}
-
+
{
byte b = to_byte<12>();
CHECK(static_cast<unsigned char>(b) == 12);
@@ -114,6 +114,20 @@ SUITE(byte_tests)
// CHECK(0x12 == gsl::to_integer<float>(b)); // expect compile-time error
// CHECK(0x12 == gsl::to_integer<double>(b)); // expect compile-time error
}
+
+ int modify_both(gsl::byte& b, int& i)
+ {
+ i = 10;
+ b = to_byte<5>();
+ return i;
+ }
+
+ TEST(aliasing)
+ {
+ int i{ 0 };
+ int res = modify_both(reinterpret_cast<byte&>(i), i);
+ CHECK(res == i);
+ }
}
}