unix: Add build script for tests
This commit is contained in:
parent
3f7b586ca2
commit
e5e83fff5c
@ -9,15 +9,18 @@ where /q cl || (
|
||||
)
|
||||
|
||||
REM MSVC cl build
|
||||
echo [SCRIPT] Building tests via cl to build\intc_tests_msvc.exe
|
||||
echo [SCRIPT] Building tests via cl to build\intc_tests_cpp_msvc.exe
|
||||
pushd build
|
||||
cl -nologo -O2 -D INTC_TESTS_WITH_MAIN -I %script_dir% -TP %script_dir%\intc_tests.h /Fe:intc_tests_msvc /link
|
||||
popd build
|
||||
cl -nologo -O2 -D INTC_TESTS_WITH_MAIN -I %script_dir% -TP %script_dir%\intc_tests.c /Fe:intc_tests_cpp_msvc /link
|
||||
|
||||
echo [SCRIPT] Building tests via cl to build\intc_tests_c_msvc.exe
|
||||
cl -nologo -O2 -D INTC_TESTS_WITH_MAIN -I %script_dir% -TC %script_dir%\intc_tests.c /Fe:intc_tests_c_msvc /link
|
||||
popd
|
||||
|
||||
REM Optional clang-cl build if we have the compiler on the path
|
||||
where /q clang-cl || goto :eof
|
||||
echo [SCRIPT] Building tests via clang-cl to build\intc_tests_clang.exe
|
||||
echo [SCRIPT] Building tests via clang-cl to build\intc_tests_cpp_clang.exe
|
||||
pushd build
|
||||
clang-cl -nologo -O2 -D INTC_TESTS_WITH_MAIN -I %script_dir% -TP %script_dir%\intc_tests.h /Fe:intc_tests_clang /link
|
||||
clang-cl -nologo -O2 -D INTC_TESTS_WITH_MAIN -I %script_dir% -TP %script_dir%\intc_tests.c /Fe:intc_tests_cpp_clang /link
|
||||
popd build
|
||||
|
||||
|
15
build_tests.sh
Normal file
15
build_tests.sh
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
script_dir="$(cd "$(dirname "$BASH_SOURCE")" && pwd)"
|
||||
mkdir --parents build
|
||||
|
||||
# GCC build
|
||||
echo "[SCRIPT] Building tests via gcc to build/intc_tests_cpp_gcc"
|
||||
pushd build
|
||||
g++ -O2 -D INTC_TESTS_WITH_MAIN -I ${script_dir} ${script_dir}/intc_tests.c -o intc_tests_cpp_gcc
|
||||
popd
|
||||
|
||||
echo "[SCRIPT] Building tests via gcc to build/intc_tests_c_gcc"
|
||||
pushd build
|
||||
gcc -O2 -D INTC_TESTS_WITH_MAIN -I ${script_dir} ${script_dir}/intc_tests.c -o intc_tests_c_gcc
|
||||
popd
|
||||
|
11
intc.h
11
intc.h
@ -152,6 +152,9 @@
|
||||
#endif
|
||||
#define INTC_ZERO_INIT {}
|
||||
#else
|
||||
#if !defined(INTC_NO_CPP_FEATURES)
|
||||
#define INTC_NO_CPP_FEATURES
|
||||
#endif
|
||||
#define INTC_BEGIN_EXTERN_C
|
||||
#define INTC_END_EXTERN_C
|
||||
#define INTC_ZERO_INIT {0}
|
||||
@ -638,10 +641,10 @@ INTC_API intc_u256 operator--(intc_u256 &lhs, int);
|
||||
#endif // INTC_H
|
||||
|
||||
#if defined(INTC_IMPLEMENTATION)
|
||||
static bool const INTC__U8_IS_8_BITS [sizeof(intc_u8) == 1 ? 1 : -1] = {};
|
||||
static bool const INTC__U16_IS_16_BITS[sizeof(intc_u16) == 2 ? 1 : -1] = {};
|
||||
static bool const INTC__U32_IS_32_BITS[sizeof(intc_u32) == 4 ? 1 : -1] = {};
|
||||
static bool const INTC__U64_IS_64_BITS[sizeof(intc_u64) == 8 ? 1 : -1] = {};
|
||||
static bool const INTC__U8_IS_8_BITS [sizeof(intc_u8) == 1 ? 1 : -1] = INTC_ZERO_INIT;
|
||||
static bool const INTC__U16_IS_16_BITS[sizeof(intc_u16) == 2 ? 1 : -1] = INTC_ZERO_INIT;
|
||||
static bool const INTC__U32_IS_32_BITS[sizeof(intc_u32) == 4 ? 1 : -1] = INTC_ZERO_INIT;
|
||||
static bool const INTC__U64_IS_64_BITS[sizeof(intc_u64) == 8 ? 1 : -1] = INTC_ZERO_INIT;
|
||||
|
||||
INTC_BEGIN_EXTERN_C
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -1,5 +1,6 @@
|
||||
#if !defined(INTC_TESTS_H)
|
||||
#define INTC_TESTS_H
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// NOTE: Overview
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -142,7 +143,17 @@ intc_u64 const INTC_TESTS_MAX_UNSIGNED_VALUES[] = {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define INTC_TESTS_ASSERT(expr) INTC_TESTS_ASSERT_MSG(expr, 0, "")
|
||||
#define INTC_TESTS_ASSERT(expr) \
|
||||
do \
|
||||
{ \
|
||||
if (!(expr)) \
|
||||
{ \
|
||||
test_case_.failed = true; \
|
||||
char const *file = intc_strip_path_to_file(__FILE__); \
|
||||
printf(" +--Test failed at %s:%d, expression was: %s\n", file, __LINE__, #expr); \
|
||||
printf(" V\n"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#if defined(INTC_TESTS_NO_COLORS)
|
||||
#define INTC_TESTS_COLOR_RED
|
||||
@ -630,8 +641,8 @@ struct intc_test_state intc_u128_unit_tests(void)
|
||||
bool f = false;
|
||||
intc_u8 u8 = 0xffULL;
|
||||
intc_u16 u16 = 0xffffULL;
|
||||
intc_u32 u32 = 0xffffffffULL;
|
||||
intc_u64 u64 = 0xffffffffffffffffULL;
|
||||
intc_u32 u32 = 0xffffffff;
|
||||
intc_u64 u64 = 0xffffffffffffffff;
|
||||
struct intc_u128 const u128 = INTC_U128(0xffffffffffffffffULL, 0xffffffffffffffffULL);
|
||||
|
||||
INTC_TESTS_ASSERT(intc_u128_eq(intc_u128_lshift(INTC_U64_TO_U128(u8), 7), INTC_U64_TO_U128(0x7f80ULL)));
|
Loading…
Reference in New Issue
Block a user