diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index e9183fc..bf8fb2e 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -10,13 +10,10 @@ jobs:
build:
strategy:
matrix:
- os: [ubuntu-latest, windows-latest, macos-13, macos-latest]
+ os: [ubuntu-latest, windows-latest, macos-latest]
type: [Debug, RelWithDebInfo, MinSizeRel, Release]
compiler: [default, clang, gcc, tcc]
exclude:
- - {os: "macos-13", compiler: "clang"}
- - {os: "macos-13", compiler: "gcc"}
- - {os: "macos-13", compiler: "tcc"}
- {os: "macos-latest", compiler: "clang"}
- {os: "macos-latest", compiler: "gcc"}
- {os: "macos-latest", compiler: "tcc"}
@@ -74,4 +71,4 @@ jobs:
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
- run: if [ "${{ matrix.os }}" == "windows-latest" ]; then cd ${{ matrix.type }}; fi; ./hashmap_test
+ run: ctest --rerun-failed --output-on-failure -C ${{ matrix.type }}
diff --git a/.github/workflows/sanitizers.yaml b/.github/workflows/sanitizers.yaml
deleted file mode 100644
index 14c988a..0000000
--- a/.github/workflows/sanitizers.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
-name: Sanitizers
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- build:
- strategy:
- matrix:
- os: [ubuntu-latest, macOS-latest]
- type: [Debug, RelWithDebInfo, MinSizeRel, Release]
- sanitizer: [address, memory, undefined]
- exclude:
- - {os: "macOS-latest", sanitizer: "memory"}
- runs-on: ${{ matrix.os }}
-
- steps:
- - uses: actions/checkout@v2
-
- - name: Create Build Environment
- run: cmake -E make_directory ${{github.workspace}}/build
-
- - name: Setup dependencies
- if: startsWith(matrix.os, 'ubuntu')
- run: sudo apt-get install -y clang
-
- - name: Configure CMake (macOS)
- shell: bash
- if: startsWith(matrix.os, 'macOS')
- working-directory: ${{github.workspace}}/build
- run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DHASHMAP_USE_SANITIZER=${{ matrix.sanitizer }}
-
- - name: Configure CMake with Clang (Ubuntu)
- shell: bash
- if: startsWith(matrix.os, 'ubuntu')
- working-directory: ${{github.workspace}}/build
- run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DHASHMAP_USE_SANITIZER=${{ matrix.sanitizer }}
-
- - name: Build
- working-directory: ${{github.workspace}}/build
- shell: bash
- run: cmake --build . --config ${{ matrix.type }}
-
- - name: Test
- working-directory: ${{github.workspace}}/build
- shell: bash
- run: ./hashmap_test
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 553ecbd..2cb58ad 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -23,113 +23,209 @@
#
# For more information, please refer to
-project(hashmap)
cmake_minimum_required(VERSION 3.15)
+project(hashmap)
-set(HASHMAP_USE_SANITIZER "" CACHE STRING "Set which Clang Sanitizer to use")
+include(CTest)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+# Base warning flags and whether -std= flags are supported.
+# MSVC and clang-cl use /std: and don't accept -std=, so we skip
+# the standard flag for those compilers.
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
- set_source_files_properties(main.c test.c PROPERTIES
- COMPILE_FLAGS "-Wall -Wextra -Werror -std=gnu89"
- )
-elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
- if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
- set_source_files_properties(main.c test.c PROPERTIES
- COMPILE_FLAGS "/Wall /WX /wd4514 /wd5045"
- )
+ set(HASHMAP_C_WARNINGS "-Wall -Wextra -Werror")
+ set(HASHMAP_C_USE_STD_FLAG TRUE)
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
+ if(CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
+ set(HASHMAP_C_WARNINGS "/Wall /WX /wd4514 /wd5045")
+ set(HASHMAP_C_USE_STD_FLAG FALSE)
else()
- set_source_files_properties(main.c test.c PROPERTIES
- COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror -std=gnu89"
- )
+ set(HASHMAP_C_WARNINGS "-Wall -Wextra -Weverything -Werror -Wno-poison-system-directories")
+ set(HASHMAP_C_USE_STD_FLAG TRUE)
endif()
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
- set_source_files_properties(main.c test.c PROPERTIES
- COMPILE_FLAGS "/Wall /WX /wd4514 /wd5045"
- )
+ set(HASHMAP_C_WARNINGS "/Wall /WX /wd4514 /wd5045")
+ set(HASHMAP_C_USE_STD_FLAG FALSE)
else()
- message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
+ message(WARNING "Unknown C compiler '${CMAKE_C_COMPILER_ID}'!")
+ set(HASHMAP_C_WARNINGS "")
+ set(HASHMAP_C_USE_STD_FLAG FALSE)
endif()
+# Only Unix-style Clang drivers understand -Wno-c++98-compat.
+set(HASHMAP_CXX98_COMPAT_FLAG "")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set_source_files_properties(test.cpp PROPERTIES
- COMPILE_FLAGS "-Wall -Wextra -Werror -std=gnu++98"
- )
-elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set(HASHMAP_CXX_WARNINGS "-Wall -Wextra -Werror")
+ set(HASHMAP_CXX_USE_STD_FLAG TRUE)
+elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
- set_source_files_properties(test.cpp PROPERTIES
- COMPILE_FLAGS "/Wall /WX /wd4514 /wd5045"
- )
+ set(HASHMAP_CXX_WARNINGS "/Wall /WX /wd4514 /wd5045")
+ set(HASHMAP_CXX_USE_STD_FLAG FALSE)
else()
- set_source_files_properties(test.cpp PROPERTIES
- COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror -std=gnu++98"
- )
+ set(HASHMAP_CXX_WARNINGS "-Wall -Wextra -Weverything -Werror -Wno-poison-system-directories")
+ set(HASHMAP_CXX_USE_STD_FLAG TRUE)
+ set(HASHMAP_CXX98_COMPAT_FLAG "-Wno-c++98-compat")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
- set_source_files_properties(test.cpp PROPERTIES
- COMPILE_FLAGS "/Wall /WX /wd4514 /wd5045"
- )
+ set(HASHMAP_CXX_WARNINGS "/Wall /WX /wd4514 /wd5045")
+ set(HASHMAP_CXX_USE_STD_FLAG FALSE)
else()
- message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
+ message(WARNING "Unknown C++ compiler '${CMAKE_CXX_COMPILER_ID}'!")
+ set(HASHMAP_CXX_WARNINGS "")
+ set(HASHMAP_CXX_USE_STD_FLAG FALSE)
endif()
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set_source_files_properties(test11.cpp PROPERTIES
- COMPILE_FLAGS "-Wall -Wextra -Werror -std=c++11"
- )
-elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
- set_source_files_properties(test11.cpp PROPERTIES
- COMPILE_FLAGS "/Wall /WX /wd4514 /wd5045"
- )
+# Helper: set compile flags for a C source file (warnings + standard + extras).
+function(hashmap_set_c_flags FILE STANDARD)
+ set(EXTRA_FLAGS ${ARGN})
+ if(HASHMAP_C_USE_STD_FLAG)
+ set_source_files_properties(${FILE} PROPERTIES
+ COMPILE_FLAGS "${HASHMAP_C_WARNINGS} ${STANDARD} ${EXTRA_FLAGS}")
else()
- set_source_files_properties(test11.cpp PROPERTIES
- COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror -std=c++11"
- )
+ set_source_files_properties(${FILE} PROPERTIES
+ COMPILE_FLAGS "${HASHMAP_C_WARNINGS} ${EXTRA_FLAGS}")
endif()
-elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
- set_source_files_properties(test11.cpp PROPERTIES
- COMPILE_FLAGS "/Wall /WX /wd4514 /wd5045"
- )
-else()
- message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
+endfunction()
+
+# Helper: set compile flags for a C++ source file (warnings + standard + extras).
+function(hashmap_set_cxx_flags FILE STANDARD)
+ set(EXTRA_FLAGS ${ARGN})
+ if(HASHMAP_CXX_USE_STD_FLAG)
+ set_source_files_properties(${FILE} PROPERTIES
+ COMPILE_FLAGS "${HASHMAP_CXX_WARNINGS} ${STANDARD} ${EXTRA_FLAGS}")
+ else()
+ set_source_files_properties(${FILE} PROPERTIES
+ COMPILE_FLAGS "${HASHMAP_CXX_WARNINGS} ${EXTRA_FLAGS}")
+ endif()
+endfunction()
+
+# C files — each compiled under a specific C standard.
+hashmap_set_c_flags(main.c "-std=gnu89")
+hashmap_set_c_flags(test.c "-std=gnu89")
+hashmap_set_c_flags(test99.c "-std=c99")
+
+list(FIND CMAKE_C_COMPILE_FEATURES c_std_11 IDX)
+if(${IDX} GREATER -1)
+ hashmap_set_c_flags(test11.c "-std=c11")
endif()
-if (NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
- if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
- set_source_files_properties(test_sse42.c PROPERTIES
- COMPILE_FLAGS "-Wall -Wextra -Werror -std=gnu89 -msse4.2"
- )
- elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
- if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
- set_source_files_properties(test_sse42.c PROPERTIES
- COMPILE_FLAGS "/Wall /WX /wd4514 /wd5045 /arch:AVX"
- )
- else()
- set_source_files_properties(test_sse42.c PROPERTIES
- COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror -std=gnu89 -msse4.2"
- )
- endif()
- elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
- set_source_files_properties(test_sse42.c PROPERTIES
- COMPILE_FLAGS "/Wall /WX /wd4514 /wd5045 /arch:AVX"
- )
+# Exercise the SSE4.2 hashing path when the target supports it.
+if(NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
+ if(MSVC OR CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
+ hashmap_set_c_flags(test_sse42.c "-std=gnu89" "/arch:AVX")
else()
- message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
+ hashmap_set_c_flags(test_sse42.c "-std=gnu89" "-msse4.2")
endif()
endif()
-add_executable(hashmap_test
+# C++ files — each compiled under a specific C++ standard.
+hashmap_set_cxx_flags(test.cpp "" ${HASHMAP_CXX98_COMPAT_FLAG})
+hashmap_set_cxx_flags(test98.cpp "-std=gnu++98")
+hashmap_set_cxx_flags(test11.cpp "-std=c++11" ${HASHMAP_CXX98_COMPAT_FLAG})
+hashmap_set_cxx_flags(test14.cpp "-std=c++14" ${HASHMAP_CXX98_COMPAT_FLAG})
+hashmap_set_cxx_flags(test17.cpp "-std=c++17" ${HASHMAP_CXX98_COMPAT_FLAG})
+hashmap_set_cxx_flags(test20.cpp "-std=c++20" ${HASHMAP_CXX98_COMPAT_FLAG})
+
+set(HASHMAP_TEST_SOURCES
../hashmap.h
+ utest.h
+ test_shared.h
main.c
test.c
+ test99.c
+ test11.c
test_sse42.c
test.cpp
+ test98.cpp
test11.cpp
+ test14.cpp
+ test17.cpp
+ test20.cpp
)
-if(NOT "${HASHMAP_USE_SANITIZER}" STREQUAL "")
- target_compile_options(hashmap_test PUBLIC -fno-omit-frame-pointer -fsanitize=${HASHMAP_USE_SANITIZER})
- target_link_options(hashmap_test PUBLIC -fno-omit-frame-pointer -fsanitize=${HASHMAP_USE_SANITIZER})
+# Helper: add a test executable and register it with CTest.
+function(hashmap_add_test NAME)
+ add_executable(${NAME} ${HASHMAP_TEST_SOURCES})
+ add_test(NAME ${NAME} COMMAND $)
+endfunction()
+
+hashmap_add_test(hashmap_test)
+
+if(MSVC)
+ # Build a second test binary linked against the static CRT (/MT)
+ # to ensure we work with both static and dynamic libc linkage.
+ set_property(TARGET hashmap_test PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL")
+ hashmap_add_test(hashmap_mt_test)
+ set_property(TARGET hashmap_mt_test PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>")
+endif()
+
+# Some sanitizer runtimes can't initialise on every host even when
+# the toolchain links them fine — e.g. clang's TSan and MSan on
+# aarch64 only ship shadow-memory layouts for 39-, 42- and 48-bit
+# user VMAs, but Raspberry Pi OS' kernel is configured with
+# CONFIG_ARM64_VA_BITS=47. The binary builds, but aborts before
+# main with "FATAL: ThreadSanitizer: unsupported VMA range". Probe
+# each candidate sanitizer with try_run and skip the ones whose
+# runtime can't start. Result is cached so reconfigure is cheap;
+# delete CMakeCache.txt to re-probe (e.g. after changing kernels).
+function(hashmap_check_sanitizer_runs SAN OUT_VAR)
+ set(CACHE_VAR "HASHMAP_SAN_${SAN}_RUNS")
+ if(DEFINED ${CACHE_VAR})
+ set(${OUT_VAR} ${${CACHE_VAR}} PARENT_SCOPE)
+ return()
+ endif()
+
+ set(PROBE_SRC "${CMAKE_BINARY_DIR}/hashmap_san_probe_${SAN}.c")
+ file(WRITE "${PROBE_SRC}" "int main(void) { return 0; }\n")
+
+ try_run(RUN_RESULT COMPILE_RESULT
+ "${CMAKE_BINARY_DIR}/hashmap_san_probe_${SAN}"
+ "${PROBE_SRC}"
+ COMPILE_DEFINITIONS "-fsanitize=${SAN}" "-fno-omit-frame-pointer"
+ LINK_OPTIONS "-fsanitize=${SAN}"
+ )
+
+ if(COMPILE_RESULT AND "${RUN_RESULT}" STREQUAL "0")
+ set(RESULT TRUE)
+ message(STATUS "Sanitizer ${SAN}: usable")
+ else()
+ set(RESULT FALSE)
+ message(STATUS "Sanitizer ${SAN}: skipping "
+ "(compile=${COMPILE_RESULT}, run=${RUN_RESULT})")
+ endif()
+
+ set(${CACHE_VAR} ${RESULT} CACHE INTERNAL
+ "Whether the ${SAN} sanitizer runtime starts on this host")
+ set(${OUT_VAR} ${RESULT} PARENT_SCOPE)
+endfunction()
+
+if(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") AND NOT "${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC")
+ set(HASHMAP_SANITIZER_CANDIDATES
+ address
+ undefined
+ thread
+ )
+
+ if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
+ set(HASHMAP_SANITIZER_CANDIDATES ${HASHMAP_SANITIZER_CANDIDATES} memory)
+ endif()
+
+ set(HASHMAP_SANITIZERS)
+ foreach(HASHMAP_SANITIZER ${HASHMAP_SANITIZER_CANDIDATES})
+ if(CMAKE_CROSSCOMPILING)
+ list(APPEND HASHMAP_SANITIZERS ${HASHMAP_SANITIZER})
+ else()
+ hashmap_check_sanitizer_runs(${HASHMAP_SANITIZER} HASHMAP_SAN_RUNS)
+ if(HASHMAP_SAN_RUNS)
+ list(APPEND HASHMAP_SANITIZERS ${HASHMAP_SANITIZER})
+ endif()
+ endif()
+ endforeach()
+
+ foreach(HASHMAP_SANITIZER ${HASHMAP_SANITIZERS})
+ hashmap_add_test(hashmap_${HASHMAP_SANITIZER}_test)
+ target_compile_options(hashmap_${HASHMAP_SANITIZER}_test PRIVATE -fsanitize=${HASHMAP_SANITIZER} -fno-omit-frame-pointer)
+ target_link_options(hashmap_${HASHMAP_SANITIZER}_test PRIVATE -fsanitize=${HASHMAP_SANITIZER})
+ endforeach()
endif()
diff --git a/test/test.c b/test/test.c
index 5440670..ae8b9df 100644
--- a/test/test.c
+++ b/test/test.c
@@ -1,6 +1,5 @@
#include "hashmap.h"
#include "utest.h"
-#define MY_TEST_WRAPPER(name) UTEST(c, name)
-
-#include "test.inc"
+#define HASHMAP_SUITE c
+#include "test_shared.h"
diff --git a/test/test.cpp b/test/test.cpp
index b345a57..68255d6 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -1,6 +1,5 @@
#include "hashmap.h"
#include "utest.h"
-#define MY_TEST_WRAPPER(name) UTEST(cpp, name)
-
-#include "test.inc"
+#define HASHMAP_SUITE cpp
+#include "test_shared.h"
diff --git a/test/test11.c b/test/test11.c
new file mode 100644
index 0000000..1cdddd2
--- /dev/null
+++ b/test/test11.c
@@ -0,0 +1,5 @@
+#include "hashmap.h"
+#include "utest.h"
+
+#define HASHMAP_SUITE c11
+#include "test_shared.h"
diff --git a/test/test11.cpp b/test/test11.cpp
index 3fbead5..9fbee8e 100644
--- a/test/test11.cpp
+++ b/test/test11.cpp
@@ -1,6 +1,5 @@
#include "hashmap.h"
#include "utest.h"
-#define MY_TEST_WRAPPER(name) UTEST(cpp11, name)
-
-#include "test.inc"
+#define HASHMAP_SUITE cpp11
+#include "test_shared.h"
diff --git a/test/test14.cpp b/test/test14.cpp
new file mode 100644
index 0000000..d332368
--- /dev/null
+++ b/test/test14.cpp
@@ -0,0 +1,5 @@
+#include "hashmap.h"
+#include "utest.h"
+
+#define HASHMAP_SUITE cpp14
+#include "test_shared.h"
diff --git a/test/test17.cpp b/test/test17.cpp
new file mode 100644
index 0000000..46b514b
--- /dev/null
+++ b/test/test17.cpp
@@ -0,0 +1,5 @@
+#include "hashmap.h"
+#include "utest.h"
+
+#define HASHMAP_SUITE cpp17
+#include "test_shared.h"
diff --git a/test/test20.cpp b/test/test20.cpp
new file mode 100644
index 0000000..fd5bc9f
--- /dev/null
+++ b/test/test20.cpp
@@ -0,0 +1,5 @@
+#include "hashmap.h"
+#include "utest.h"
+
+#define HASHMAP_SUITE cpp20
+#include "test_shared.h"
diff --git a/test/test98.cpp b/test/test98.cpp
new file mode 100644
index 0000000..63a20db
--- /dev/null
+++ b/test/test98.cpp
@@ -0,0 +1,5 @@
+#include "hashmap.h"
+#include "utest.h"
+
+#define HASHMAP_SUITE cpp98
+#include "test_shared.h"
diff --git a/test/test99.c b/test/test99.c
new file mode 100644
index 0000000..4bb0e3a
--- /dev/null
+++ b/test/test99.c
@@ -0,0 +1,5 @@
+#include "hashmap.h"
+#include "utest.h"
+
+#define HASHMAP_SUITE c99
+#include "test_shared.h"
diff --git a/test/test.inc b/test/test_shared.h
similarity index 89%
rename from test/test.inc
rename to test/test_shared.h
index 270e24a..13e4ba2 100644
--- a/test/test.inc
+++ b/test/test_shared.h
@@ -1,3 +1,19 @@
+/* Shared test cases for hashmap.h.
+
+ Each test translation unit must define HASHMAP_SUITE before including this
+ header: #define HASHMAP_SUITE c #include "test_shared.h"
+
+ The HASHMAP_TEST macro expands HASHMAP_SUITE before UTEST token pasting,
+ giving each standard-specific translation unit unique test symbols.
+*/
+
+#ifndef HASHMAP_SUITE
+#error "Define HASHMAP_SUITE before including test_shared.h"
+#endif
+
+#define HASHMAP_TEST2(suite, name) UTEST(suite, name)
+#define HASHMAP_TEST(name) HASHMAP_TEST2(HASHMAP_SUITE, name)
+
#if defined(__cplusplus) && (__cplusplus >= 201103L) && defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat"
@@ -22,20 +38,20 @@
#include
-MY_TEST_WRAPPER(create) {
+HASHMAP_TEST(create) {
struct hashmap_s hashmap;
ASSERT_EQ(0, hashmap_create(1, &hashmap));
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(create_zero) {
+HASHMAP_TEST(create_zero) {
struct hashmap_s hashmap;
ASSERT_EQ(0, hashmap_create(0, &hashmap));
ASSERT_LT(0u, hashmap_capacity(&hashmap));
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(create_not_power_of_two) {
+HASHMAP_TEST(create_not_power_of_two) {
struct hashmap_s hashmap;
ASSERT_EQ(0, hashmap_create(3, &hashmap));
ASSERT_LE(3u, hashmap_capacity(&hashmap));
@@ -59,7 +75,7 @@ static int custom_comparer(const void *const a, const hashmap_uint32_t a_len,
HASHMAP_PTR_CAST(const char *, b), a_len);
}
-MY_TEST_WRAPPER(create_ex) {
+HASHMAP_TEST(create_ex) {
int thing = 42;
const char *const key = "foo";
struct hashmap_s hashmap;
@@ -91,7 +107,7 @@ static int NOTHROW set_context(void *const context,
return 1;
}
-MY_TEST_WRAPPER(put) {
+HASHMAP_TEST(put) {
struct hashmap_s hashmap;
int x = 42;
int y = 13;
@@ -103,7 +119,7 @@ MY_TEST_WRAPPER(put) {
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(get_exists) {
+HASHMAP_TEST(get_exists) {
struct hashmap_s hashmap;
int x = 42;
ASSERT_EQ(0, hashmap_create(1, &hashmap));
@@ -115,7 +131,7 @@ MY_TEST_WRAPPER(get_exists) {
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(get_does_not_exists) {
+HASHMAP_TEST(get_does_not_exists) {
struct hashmap_s hashmap;
ASSERT_EQ(0, hashmap_create(1, &hashmap));
ASSERT_FALSE(
@@ -123,7 +139,7 @@ MY_TEST_WRAPPER(get_does_not_exists) {
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(remove) {
+HASHMAP_TEST(remove) {
struct hashmap_s hashmap;
int x = 42;
ASSERT_EQ(0, hashmap_create(1, &hashmap));
@@ -134,7 +150,7 @@ MY_TEST_WRAPPER(remove) {
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(remove_and_return_key) {
+HASHMAP_TEST(remove_and_return_key) {
/* The '&bar' portion of the string just uniques the constant from the 'foo'
* used later. */
const char *const key = "foo&bar";
@@ -159,7 +175,7 @@ static int NOTHROW early_exit(void *const context, void *const element) {
return 0;
}
-MY_TEST_WRAPPER(iterate_early_exit) {
+HASHMAP_TEST(iterate_early_exit) {
struct hashmap_s hashmap;
int x[27] = {0};
int total = 0;
@@ -200,7 +216,7 @@ static int NOTHROW all(void *const context, void *const element) {
return 1;
}
-MY_TEST_WRAPPER(iterate_all) {
+HASHMAP_TEST(iterate_all) {
struct hashmap_s hashmap;
int x[27] = {0};
int total = 0;
@@ -228,7 +244,7 @@ MY_TEST_WRAPPER(iterate_all) {
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(num_entries) {
+HASHMAP_TEST(num_entries) {
struct hashmap_s hashmap;
int x = 42;
ASSERT_EQ(0, hashmap_create(1, &hashmap));
@@ -242,7 +258,7 @@ MY_TEST_WRAPPER(num_entries) {
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(hash_conflict) {
+HASHMAP_TEST(hash_conflict) {
struct hashmap_s hashmap;
int x = 42;
@@ -270,7 +286,7 @@ MY_TEST_WRAPPER(hash_conflict) {
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(issue_20) {
+HASHMAP_TEST(issue_20) {
struct hashmap_s hashmap;
const char *key = "192.168.2.2hv_api.udache.com/abc/def";
unsigned int len = HASHMAP_CAST(unsigned, strlen(key));
@@ -288,7 +304,7 @@ MY_TEST_WRAPPER(issue_20) {
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(one_byte) {
+HASHMAP_TEST(one_byte) {
unsigned char data[256];
int i;
struct hashmap_s hashmap;
@@ -309,7 +325,7 @@ MY_TEST_WRAPPER(one_byte) {
hashmap_destroy(&hashmap);
}
-MY_TEST_WRAPPER(two_bytes) {
+HASHMAP_TEST(two_bytes) {
unsigned short *data;
int i;
struct hashmap_s hashmap;
diff --git a/test/test_sse42.c b/test/test_sse42.c
index 99c1c34..9cc9e34 100644
--- a/test/test_sse42.c
+++ b/test/test_sse42.c
@@ -1,11 +1,10 @@
#include "hashmap.h"
#include "utest.h"
-#if (defined(_MSC_VER) && defined(__AVX__)) || \
+#if (defined(_MSC_VER) && defined(__AVX__)) || \
(!defined(_MSC_VER) && defined(__SSE4_2__))
-#define MY_TEST_WRAPPER(name) UTEST(c_sse2, name)
-
-#include "test.inc"
+#define HASHMAP_SUITE c_sse42
+#include "test_shared.h"
#endif