diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-05-11 10:38:23 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-05-11 13:14:13 -0400 |
commit | 7e26443627926bb3bcc88bd790190d5e4e0eda98 (patch) | |
tree | 02844b8dac09348f39fcb599f1033807cb4b66e6 /tests/bfstd.c | |
parent | 59f87eed2b930af2f31fd1d1fb2589f80f426ee0 (diff) | |
download | bfs-7e26443627926bb3bcc88bd790190d5e4e0eda98.tar.xz |
config: Properly align flex_sizeof()
Diffstat (limited to 'tests/bfstd.c')
-rw-r--r-- | tests/bfstd.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/bfstd.c b/tests/bfstd.c index 8c61072..c6a9e9f 100644 --- a/tests/bfstd.c +++ b/tests/bfstd.c @@ -1,8 +1,12 @@ // Copyright © Tavian Barnes <tavianator@tavianator.com> // SPDX-License-Identifier: 0BSD +#undef NDEBUG #include "../src/bfstd.h" +#include "../src/config.h" +#include <assert.h> #include <stdio.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> @@ -30,6 +34,15 @@ static void check_base_dir(const char *path, const char *dir, const char *base) } int main(void) { + // Check flex_sizeof() + struct flexible { + alignas(64) int foo; + int bar[]; + }; + assert(flex_sizeof(struct flexible, bar, 0) >= sizeof(struct flexible)); + assert(flex_sizeof(struct flexible, bar, 16) % alignof(struct flexible) == 0); + assert(flex_sizeof_impl(8, 16, 4, 4, 1) == 16); + // From man 3p basename check_base_dir("usr", ".", "usr"); check_base_dir("usr/", ".", "usr"); |