24
#include "precompiled.hpp"
25
#include "gc/x/xBitField.hpp"
26
#include "unittest.hpp"
28
TEST(XBitFieldTest, test) {
29
typedef XBitField<uint64_t, bool, 0, 1> field_bool;
30
typedef XBitField<uint64_t, uint8_t, 1, 8> field_uint8;
31
typedef XBitField<uint64_t, uint16_t, 2, 16> field_uint16;
32
typedef XBitField<uint64_t, uint32_t, 32, 32> field_uint32;
33
typedef XBitField<uint64_t, uint64_t, 0, 63> field_uint64;
34
typedef XBitField<uint64_t, void*, 1, 61, 3> field_pointer;
39
const bool value = false;
40
entry = field_bool::encode(value);
41
EXPECT_EQ(field_bool::decode(entry), value) << "Should be equal";
45
const bool value = true;
46
entry = field_bool::encode(value);
47
EXPECT_EQ(field_bool::decode(entry), value) << "Should be equal";
51
const uint8_t value = ~(uint8_t)0;
52
entry = field_uint8::encode(value);
53
EXPECT_EQ(field_uint8::decode(entry), value) << "Should be equal";
57
const uint16_t value = ~(uint16_t)0;
58
entry = field_uint16::encode(value);
59
EXPECT_EQ(field_uint16::decode(entry), value) << "Should be equal";
63
const uint32_t value = ~(uint32_t)0;
64
entry = field_uint32::encode(value);
65
EXPECT_EQ(field_uint32::decode(entry), value) << "Should be equal";
69
const uint64_t value = ~(uint64_t)0 >> 1;
70
entry = field_uint64::encode(value);
71
EXPECT_EQ(field_uint64::decode(entry), value) << "Should be equal";
75
void* const value = (void*)(~(uintptr_t)0 << 3);
76
entry = field_pointer::encode(value);
77
EXPECT_EQ(field_pointer::decode(entry), value) << "Should be equal";