MCPcopy Create free account
hub / github.com/alibaba/yalantinglibs / test_pointer

Function test_pointer

src/reflection/tests/test_reflection.cpp:62–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60};
61
62void test_pointer() {
63 simple t{};
64 auto&& [o, b, c, d] = t;
65 size_t offset1 = (const char*)(&o) - (const char*)(&t);
66 size_t offset2 = (const char*)(&b) - (const char*)(&t);
67 size_t offset3 = (const char*)(&c) - (const char*)(&t);
68 size_t offset4 = (const char*)(&d) - (const char*)(&t);
69
70 const auto& offset_arr = member_offsets<simple>;
71 CHECK(offset_arr[0] == offset1);
72 CHECK(offset_arr[1] == offset2);
73 CHECK(offset_arr[2] == offset3);
74 CHECK(offset_arr[3] == offset4);
75}
76
77TEST_CASE("test member pointer and offset") { test_pointer(); }
78

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected