# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)

if(HAVE_BOOST_TEST)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

set(BOOST_TEST_LINK_LIBRARIES Boost::unordered Boost::core Boost::concept_check Boost::tuple)

function(fca_tests)
  boost_test(PREFIX boost_unordered ${ARGN})
endfunction()

function(foa_tests)
  boost_test(PREFIX boost_unordered_foa COMPILE_DEFINITIONS BOOST_UNORDERED_FOA_TESTS ${ARGN})
endfunction()

function(cfoa_tests)
  boost_test(PREFIX boost_unordered_cfoa LINK_LIBRARIES Boost::compat Boost::iterator Threads::Threads ${ARGN})
endfunction()

# FCA tests

fca_tests(SOURCES unordered/prime_fmod_tests.cpp)
fca_tests(SOURCES unordered/fwd_set_test.cpp)
fca_tests(SOURCES unordered/fwd_map_test.cpp)
fca_tests(SOURCES unordered/allocator_traits.cpp)
fca_tests(SOURCES unordered/minimal_allocator.cpp)
fca_tests(SOURCES unordered/compile_set.cpp)
fca_tests(SOURCES unordered/compile_map.cpp)
fca_tests(SOURCES unordered/noexcept_tests.cpp)
fca_tests(SOURCES unordered/link_test_1.cpp unordered/link_test_2.cpp)
fca_tests(SOURCES unordered/incomplete_test.cpp)
fca_tests(SOURCES unordered/simple_tests.cpp)
fca_tests(SOURCES unordered/equivalent_keys_tests.cpp)
fca_tests(SOURCES unordered/constructor_tests.cpp)
fca_tests(SOURCES unordered/copy_tests.cpp)
fca_tests(SOURCES unordered/move_tests.cpp)
fca_tests(SOURCES unordered/post_move_tests.cpp)
fca_tests(SOURCES unordered/assign_tests.cpp)
fca_tests(SOURCES unordered/insert_tests.cpp)
fca_tests(SOURCES unordered/insert_stable_tests.cpp)
fca_tests(SOURCES unordered/insert_hint_tests.cpp)
fca_tests(SOURCES unordered/emplace_tests.cpp)
fca_tests(SOURCES unordered/unnecessary_copy_tests.cpp)
fca_tests(SOURCES unordered/erase_tests.cpp COMPILE_DEFINITIONS BOOST_UNORDERED_SUPPRESS_DEPRECATED)
fca_tests(SOURCES unordered/erase_equiv_tests.cpp)
fca_tests(SOURCES unordered/extract_tests.cpp)
fca_tests(SOURCES unordered/node_handle_tests.cpp)
fca_tests(SOURCES unordered/merge_tests.cpp)
fca_tests(SOURCES unordered/find_tests.cpp)
fca_tests(SOURCES unordered/at_tests.cpp)
fca_tests(SOURCES unordered/bucket_tests.cpp)
fca_tests(SOURCES unordered/load_factor_tests.cpp)
fca_tests(SOURCES unordered/rehash_tests.cpp)
fca_tests(SOURCES unordered/equality_tests.cpp)
fca_tests(SOURCES unordered/swap_tests.cpp)
fca_tests(SOURCES unordered/deduction_tests.cpp)
fca_tests(SOURCES unordered/scoped_allocator.cpp)
fca_tests(SOURCES unordered/transparent_tests.cpp)
fca_tests(SOURCES unordered/reserve_tests.cpp)
fca_tests(SOURCES unordered/contains_tests.cpp)
fca_tests(SOURCES unordered/erase_if.cpp)
fca_tests(SOURCES unordered/scary_tests.cpp)
fca_tests(SOURCES exception/constructor_exception_tests.cpp)
fca_tests(SOURCES exception/copy_exception_tests.cpp)
fca_tests(SOURCES exception/assign_exception_tests.cpp)
fca_tests(SOURCES exception/move_assign_exception_tests.cpp)
fca_tests(SOURCES exception/insert_exception_tests.cpp)
fca_tests(SOURCES exception/erase_exception_tests.cpp)
fca_tests(SOURCES exception/rehash_exception_tests.cpp)
fca_tests(SOURCES exception/swap_exception_tests.cpp COMPILE_DEFINITIONS BOOST_UNORDERED_SWAP_METHOD=2)
fca_tests(SOURCES exception/merge_exception_tests.cpp)
fca_tests(SOURCES exception/less_tests.cpp)
fca_tests(SOURCES unordered/narrow_cast_tests.cpp)
fca_tests(SOURCES quick.cpp)

fca_tests(TYPE compile-fail NAME insert_node_type_fail_map COMPILE_DEFINITIONS UNORDERED_TEST_MAP SOURCES unordered/insert_node_type_fail.cpp)
fca_tests(TYPE compile-fail NAME insert_node_type_fail_multimap COMPILE_DEFINITIONS UNORDERED_TEST_MULTIMAP SOURCES unordered/insert_node_type_fail.cpp)
fca_tests(TYPE compile-fail NAME insert_node_type_fail_set COMPILE_DEFINITIONS UNORDERED_TEST_SET SOURCES unordered/insert_node_type_fail.cpp)
fca_tests(TYPE compile-fail NAME insert_node_type_fail_multiset COMPILE_DEFINITIONS UNORDERED_TEST_MULTISET SOURCES unordered/insert_node_type_fail.cpp)

# FOA tests

foa_tests(SOURCES unordered/fwd_set_test.cpp)
foa_tests(SOURCES unordered/fwd_map_test.cpp)
foa_tests(SOURCES unordered/compile_set.cpp)
foa_tests(SOURCES unordered/compile_map.cpp)
foa_tests(SOURCES unordered/noexcept_tests.cpp)
foa_tests(SOURCES unordered/incomplete_test.cpp)
foa_tests(SOURCES unordered/simple_tests.cpp)
foa_tests(SOURCES unordered/equivalent_keys_tests.cpp)
foa_tests(SOURCES unordered/constructor_tests.cpp)
foa_tests(SOURCES unordered/copy_tests.cpp)
foa_tests(SOURCES unordered/move_tests.cpp)
foa_tests(SOURCES unordered/post_move_tests.cpp)
foa_tests(SOURCES unordered/assign_tests.cpp)
foa_tests(SOURCES unordered/insert_tests.cpp)
foa_tests(SOURCES unordered/insert_hint_tests.cpp)
foa_tests(SOURCES unordered/emplace_tests.cpp)
foa_tests(SOURCES unordered/erase_tests.cpp)
foa_tests(SOURCES unordered/merge_tests.cpp)
foa_tests(SOURCES unordered/find_tests.cpp)
foa_tests(SOURCES unordered/at_tests.cpp)
foa_tests(SOURCES unordered/load_factor_tests.cpp)
foa_tests(SOURCES unordered/rehash_tests.cpp)
foa_tests(SOURCES unordered/equality_tests.cpp)
foa_tests(SOURCES unordered/swap_tests.cpp)
foa_tests(SOURCES unordered/transparent_tests.cpp)
foa_tests(SOURCES unordered/reserve_tests.cpp)
foa_tests(SOURCES unordered/contains_tests.cpp)
foa_tests(SOURCES unordered/erase_if.cpp)
foa_tests(SOURCES unordered/scary_tests.cpp)
foa_tests(SOURCES unordered/init_type_insert_tests.cpp)
foa_tests(SOURCES unordered/max_load_tests.cpp)
foa_tests(SOURCES unordered/extract_tests.cpp)
foa_tests(SOURCES unordered/node_handle_tests.cpp)
foa_tests(SOURCES unordered/uses_allocator.cpp)
foa_tests(SOURCES unordered/link_test_1.cpp unordered/link_test_2.cpp )
foa_tests(SOURCES unordered/scoped_allocator.cpp)
foa_tests(SOURCES unordered/hash_is_avalanching_test.cpp)
foa_tests(SOURCES unordered/pull_tests.cpp)
foa_tests(SOURCES exception/constructor_exception_tests.cpp)
foa_tests(SOURCES exception/copy_exception_tests.cpp)
foa_tests(SOURCES exception/assign_exception_tests.cpp)
foa_tests(SOURCES exception/move_assign_exception_tests.cpp)
foa_tests(SOURCES exception/insert_exception_tests.cpp)
foa_tests(SOURCES exception/erase_exception_tests.cpp)
foa_tests(SOURCES exception/rehash_exception_tests.cpp)
foa_tests(SOURCES exception/swap_exception_tests.cpp)
foa_tests(SOURCES exception/merge_exception_tests.cpp)

# CFOA tests

cfoa_tests(SOURCES cfoa/insert_tests.cpp COMPILE_OPTIONS $<$<CXX_COMPILER_ID:MSVC>:/bigobj>)
cfoa_tests(SOURCES cfoa/erase_tests.cpp)
cfoa_tests(SOURCES cfoa/try_emplace_tests.cpp)
cfoa_tests(SOURCES cfoa/emplace_tests.cpp)
cfoa_tests(SOURCES cfoa/visit_tests.cpp)
cfoa_tests(SOURCES cfoa/constructor_tests.cpp)
cfoa_tests(SOURCES cfoa/assign_tests.cpp)
cfoa_tests(SOURCES cfoa/clear_tests.cpp)
cfoa_tests(SOURCES cfoa/swap_tests.cpp)
cfoa_tests(SOURCES cfoa/merge_tests.cpp)
cfoa_tests(SOURCES cfoa/rehash_tests.cpp)
cfoa_tests(SOURCES cfoa/equality_tests.cpp)
cfoa_tests(SOURCES cfoa/fwd_tests.cpp)
cfoa_tests(SOURCES cfoa/exception_insert_tests.cpp)
cfoa_tests(SOURCES cfoa/exception_erase_tests.cpp)
cfoa_tests(SOURCES cfoa/exception_constructor_tests.cpp)
cfoa_tests(SOURCES cfoa/exception_assign_tests.cpp)
cfoa_tests(SOURCES cfoa/exception_merge_tests.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test2.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test3.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test4.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test5.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test6.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test7.cpp)
cfoa_tests(SOURCES cfoa/rw_spinlock_test8.cpp)

# Compile tests

fca_tests(TYPE compile NAME explicit_instantiation_tests SOURCES unordered/explicit_instantiation_tests.cpp)
foa_tests(TYPE compile NAME explicit_instantiation_tests SOURCES unordered/explicit_instantiation_tests.cpp)
cfoa_tests(TYPE compile NAME explicit_instantiation_tests SOURCES cfoa/explicit_instantiation_tests.cpp)

foa_tests(TYPE compile NAME conversion_operator_tests SOURCES unordered/conversion_operator_tests.cpp)
cfoa_tests(TYPE compile NAME conversion_operator_tests SOURCES cfoa/conversion_operator_tests.cpp)

endif()
