Skip to content

Commit dd47ffc

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

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/utils/utils_linux.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

5+
#include <cstdint>
56
#include <sys/mman.h>
67

78
#include "base.hpp"
@@ -169,3 +170,19 @@ TEST_F(test, utils_open) {
169170
EXPECT_EQ(utils_file_open(NULL), -1);
170171
EXPECT_EQ(utils_file_open_or_create(NULL), -1);
171172
}
173+
174+
TEST_F(test, utils_align_ptr_up_size_down) {
175+
uintptr_t ptr = 0x4000;
176+
size_t size = 0x8000;
177+
size_t alignment = 0x4000;
178+
utils_align_ptr_up_size_down((void **)&ptr, &size, alignment);
179+
EXPECT_EQ(ptr, 0x4000);
180+
EXPECT_EQ(size, 0x8000);
181+
182+
ptr = 0x4001;
183+
size = 0x8000;
184+
alignment = 0x4000;
185+
utils_align_ptr_up_size_down((void **)&ptr, &size, alignment);
186+
EXPECT_EQ(ptr, 0x8000);
187+
EXPECT_EQ(size, 0x4001);
188+
}

0 commit comments

Comments
 (0)