diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3c3125e..2747d3f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,9 +24,9 @@ else() CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX14) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-missing-braces") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3 -Wall -Wno-missing-braces") elseif(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-missing-braces") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -Wall -Wno-missing-braces") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() diff --git a/tests/byte_tests.cpp b/tests/byte_tests.cpp index 3bbf382..32b0957 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(b) == 12); } - + { byte b = to_byte<12>(); CHECK(static_cast(b) == 12); @@ -61,6 +61,20 @@ SUITE(byte_tests) //} } + 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(&i), &i); + CHECK(res == i); + } + TEST(bitwise_operations) { byte b = to_byte<0xFF>();