You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
doctest/examples/all_features/bitfields.cpp

21 lines
447 B
C++

#include <doctest/doctest.h>
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
#include <cstdint>
#include <sstream>
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END
DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations")
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes")
struct S {
uint32_t a : 31;
uint32_t b : 1;
};
TEST_CASE("bitfield") {
S s;
s.a = 0;
s.b = 1;
CHECK(s.a == 0); // error here
}