Skip to content

Commit b2605ba

Browse files
committed
Add tests for utils_align_ptr_up_size_down()
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 4ff474f commit b2605ba

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/utils/utils_linux.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,19 @@ TEST_F(test, utils_open) {
169169
EXPECT_EQ(utils_file_open(NULL), -1);
170170
EXPECT_EQ(utils_file_open_or_create(NULL), -1);
171171
}
172+
173+
TEST_F(test, utils_align_ptr_up_size_down) {
174+
uintptr_t ptr = 0x4000;
175+
size_t size = 0x8000;
176+
size_t alignment = 0x4000;
177+
utils_align_ptr_up_size_down((void **)&ptr, &size, alignment);
178+
EXPECT_EQ(ptr, 0x4000);
179+
EXPECT_EQ(size, 0x8000);
180+
181+
ptr = 0x4001;
182+
size = 0x8000;
183+
alignment = 0x4000;
184+
utils_align_ptr_up_size_down((void **)&ptr, &size, alignment);
185+
EXPECT_EQ(ptr, 0x8000);
186+
EXPECT_EQ(size, 0x4001);
187+
}

0 commit comments

Comments
 (0)