Correct StackVec test

Change-Id: Iadd7f1ef075b975beeddc503482b33e67fa2875b
Signed-off-by: Jablonski, Mateusz <mateusz.jablonski@intel.com>
This commit is contained in:
Jablonski, Mateusz 2020-03-16 13:08:31 +01:00 committed by sys_ocldev
parent 97bad05923
commit af33d42e88
1 changed files with 13 additions and 18 deletions

View File

@ -1203,26 +1203,21 @@ TEST(StackVec, MoveAsignment) {
} }
TEST(StackVec, Alignment) { TEST(StackVec, Alignment) {
struct alignas(16) S16 { StackVec<uint16_t, 4> s16;
int a; StackVec<uint32_t, 4> s32;
}; StackVec<uint64_t, 4> s64;
struct alignas(32) S32 {
int a;
};
struct alignas(64) S64 {
int a;
};
StackVec<S32, 4> s32; static_assert(sizeof(s16) <= 24u, "");
StackVec<S16, 4> s16; static_assert(sizeof(s32) <= 32u, "");
StackVec<S64, 4> s64; static_assert(sizeof(s64) <= 48u, "");
s16.push_back(S16{});
s32.push_back(S32{});
s64.push_back(S64{});
EXPECT_EQ(0U, reinterpret_cast<uintptr_t>(&*s16.begin()) % 16); s16.push_back(0);
EXPECT_EQ(0U, reinterpret_cast<uintptr_t>(&*s32.begin()) % 32); s32.push_back(0);
EXPECT_EQ(0U, reinterpret_cast<uintptr_t>(&*s64.begin()) % 64); s64.push_back(0);
EXPECT_EQ(0U, reinterpret_cast<uintptr_t>(s16.begin()) % 2);
EXPECT_EQ(0U, reinterpret_cast<uintptr_t>(s32.begin()) % 4);
EXPECT_EQ(0U, reinterpret_cast<uintptr_t>(s64.begin()) % 8);
} }
TEST(StackVec, PushBack) { TEST(StackVec, PushBack) {