summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bx/tests/macros_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bx/tests/macros_test.cpp')
-rw-r--r--3rdparty/bx/tests/macros_test.cpp45
1 files changed, 28 insertions, 17 deletions
diff --git a/3rdparty/bx/tests/macros_test.cpp b/3rdparty/bx/tests/macros_test.cpp
index e0d5ffae8b4..75081b95d70 100644
--- a/3rdparty/bx/tests/macros_test.cpp
+++ b/3rdparty/bx/tests/macros_test.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright 2010-2018 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
+ * Copyright 2010-2022 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bx/blob/master/LICENSE
*/
#include "test.h"
@@ -13,7 +13,6 @@ BX_STATIC_ASSERT(false
|| BX_CRT_LIBCXX
|| BX_CRT_MINGW
|| BX_CRT_MSVC
- || BX_CRT_MUSL
|| BX_CRT_NEWLIB
);
@@ -24,20 +23,6 @@ BX_STATIC_ASSERT(4 == BX_VA_ARGS_COUNT(1, 2, 3, 4) );
BX_STATIC_ASSERT(5 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5) );
BX_STATIC_ASSERT(6 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5, 6) );
-BX_STATIC_ASSERT( 0 == BX_ALIGN_16( 0) );
-BX_STATIC_ASSERT( 16 == BX_ALIGN_16( 1) );
-BX_STATIC_ASSERT( 16 == BX_ALIGN_16( 15) );
-BX_STATIC_ASSERT( 16 == BX_ALIGN_16( 16) );
-BX_STATIC_ASSERT(256 == BX_ALIGN_16(255) );
-
-BX_STATIC_ASSERT( 0 == BX_ALIGN_256( 0) );
-BX_STATIC_ASSERT(256 == BX_ALIGN_256( 1) );
-BX_STATIC_ASSERT(256 == BX_ALIGN_256( 15) );
-BX_STATIC_ASSERT(256 == BX_ALIGN_256(255) );
-BX_STATIC_ASSERT(256 == BX_ALIGN_256(256) );
-BX_STATIC_ASSERT(256 == BX_ALIGN_256(256) );
-BX_STATIC_ASSERT(512 == BX_ALIGN_256(511) );
-
BX_NO_INLINE void unusedFunction()
{
CHECK(false);
@@ -62,4 +47,30 @@ TEST(macros)
CHECK_EQUAL(6, BX_VA_ARGS_COUNT(1, 2, 3, 4, 5, 6) );
CHECK_EQUAL(0, bx::strCmp(BX_STRINGIZE(TEST 1234 %^&*), "TEST 1234 %^&*") );
+
+ {
+ struct PodStruct { int32_t x, y, z; };
+ CHECK_EQUAL(0, BX_OFFSETOF(PodStruct, x) );
+ CHECK_EQUAL(4, BX_OFFSETOF(PodStruct, y) );
+ CHECK_EQUAL(8, BX_OFFSETOF(PodStruct, z) );
+ }
+
+ {
+ union PodUnion { int32_t x, y, z; };
+ CHECK_EQUAL(BX_OFFSETOF(PodUnion, x), BX_OFFSETOF(PodUnion, y) );
+ CHECK_EQUAL(BX_OFFSETOF(PodUnion, y), BX_OFFSETOF(PodUnion, z) );
+ }
+
+ {
+ struct NonPodStruct { NonPodStruct() { } int32_t x, y, z; };
+ CHECK_EQUAL(0, BX_OFFSETOF(NonPodStruct, x) );
+ CHECK_EQUAL(4, BX_OFFSETOF(NonPodStruct, y) );
+ CHECK_EQUAL(8, BX_OFFSETOF(NonPodStruct, z) );
+ }
+
+ {
+ union NonPodUnion { NonPodUnion() { } int32_t x, y, z; };
+ CHECK_EQUAL(BX_OFFSETOF(NonPodUnion, x), BX_OFFSETOF(NonPodUnion, y) );
+ CHECK_EQUAL(BX_OFFSETOF(NonPodUnion, y), BX_OFFSETOF(NonPodUnion, z) );
+ }
}