43 Bitfield<39, 32> byte5;
45 BitfieldRO<39, 32> byte5RO;
46 BitfieldWO<39, 32> byte5WO;
48 Bitfield<43, 42> bits43To42;
50 SignedBitfield<41> bit41Signed;
52 SignedBitfield<47, 40> byte6Signed;
53 SignedBitfieldRO<47, 40> byte6SignedRO;
54 SignedBitfieldWO<47, 40> byte6SignedWO;
69 struct ContainingStruct
72 Bitfield<63, 60> topNibble;
79 containingFunc(uint64_t init_val, uint64_t fieldVal)
82 Bitfield<16, 15> field;
85 Contained contained = init_val;
86 contained.field = fieldVal;
102 SixtyFour sixtyFour = 0;
106 sixtyFour.byte5 = 0xff;
108 sixtyFour.byte5 = 0xfff;
115 sixtyFour.bit2 = 0x1;
122 sixtyFour.byte5 = 0xff;
126 setCase(
"write only bitfield");
127 sixtyFour.byte5WO = 0xff;
131 setCase(
"sub bitunions and their bitfields");
133 sixtyFour.byte6 = 0x2;
135 sixtyFour.byte6.bits43To42 = 0x3;
137 sixtyFour.byte6 = 0xff;
138 sixtyFour.byte6.bit41 = 0;
142 setCase(
"normal, read only, and write only signed bitfields");
143 sixtyFour.byte6 = 0xff;
146 sixtyFour.byte6SignedWO = 0;
152 setCase(
"bitunion declared inside a struct");
153 ContainingStruct containing;
154 containing.contained = 0;
155 containing.contained.topNibble = 0xd;
156 EXPECT_EQ(containing.contained, 0xd000000000000000);
158 setCase(
"bitunion declared inside a function");
159 EXPECT_EQ(containingFunc(0xfffff, 0), 0xe7fff);
161 setCase(
"assigning bitfields to other bitfields");
162 SixtyFour otherSixtyFour = 0;
164 otherSixtyFour.byte6.bit41 = sixtyFour.bit2;
165 EXPECT_EQ(otherSixtyFour, 0x20000000000);
166 otherSixtyFour.bit2 = sixtyFour.bit2;
167 EXPECT_EQ(otherSixtyFour, 0x20000000004);
171 otherSixtyFour = 0x4;
172 sixtyFour = otherSixtyFour;
178 sixtyFour = otherSixtyFour;
EndBitUnion(UserDescFlags) struct UserDesc32
EmptySixteen emptySixteen
#define EXPECT_TRUE(expr)
A macro which verifies that expr evaluates to true.
#define SubBitUnion(name, first, last)
EmptySixtyFour emptySixtyFour
#define EndSubBitUnion(name)
void setCase(const char *newCase)
Sets the current test case.
EmptyThirtyTwo emptyThirtyTwo
BitUnion32(UserDescFlags) Bitfield< 0 > seg_32bit
unsigned printResults()
Function to call at the end of a test that prints an overall result and a summary of how many checks ...
#define EXPECT_EQ(lhs, rhs)
A macro which verifies that lhs and rhs are equal to each other.