0
0
Fork 0
mirror of https://github.com/ZDoom/fluidsynth.git synced 2024-12-04 01:51:06 +00:00
fluidsynth/test/test_pointer_alignment.c
derselbst 9382edabd5 enforce coding style guide
using astyle
2018-06-24 13:13:18 +02:00

31 lines
744 B
C

#include "test.h"
#include "utils/fluid_sys.h"
// test for fluid_align_ptr()
int main(void)
{
unsigned int align;
uintptr_t ptr, aligned_ptr;
for(align = 32; align <= 4 * 1024u; align <<= 1)
{
for(ptr = 0; ptr <= (align << 10); ptr++)
{
char *tmp = fluid_align_ptr((char *)ptr, align);
aligned_ptr = (uintptr_t)tmp;
// pointer must be aligned properly
TEST_ASSERT(aligned_ptr % align == 0);
// aligned pointer must not be smaller than ptr
TEST_ASSERT(aligned_ptr >= ptr);
// aligned pointer must not be bigger than alignment
TEST_ASSERT(aligned_ptr < ptr + align);
}
}
return EXIT_SUCCESS;
}