
# Copyright 2006-2008 Daniel James.
# Copyright 2022-2023 Christian Mazakas
# 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)

import testing ;

# Adding -Wundef is blocked on (at least)
# https://github.com/boostorg/type_traits/issues/165

local gcc-flags = -Wsign-promo -Wconversion -Wsign-conversion -Wfloat-equal -Wshadow -Wno-variadic-macros ;
local clang-flags = $(gcc-flags) -Wno-c99-extensions ;
local msvc-flags = /wd4494 ;

project
    : requirements

        <warnings>pedantic
        <toolset>intel:<warnings>on

        <toolset>gcc:<cxxflags>$(gcc-flags)
        <toolset>darwin:<cxxflags>$(gcc-flags)
        <toolset>clang:<cxxflags>$(clang-flags)
        <toolset>msvc:<cxxflags>$(msvc-flags)

        <toolset>gcc-4.4:<cxxflags>-Wno-strict-aliasing
        <toolset>gcc-4.4:<cxxflags>-fno-deduce-init-list
        <toolset>clang-14:<cxxflags>-Wunused-template

        <toolset>gcc:<warnings-as-errors>on
        <toolset>clang:<warnings-as-errors>on
        <toolset>msvc:<warnings-as-errors>on
    ;

run unordered/prime_fmod_tests.cpp ;
run unordered/fwd_set_test.cpp ;
run unordered/fwd_map_test.cpp ;
run unordered/allocator_traits.cpp ;
run unordered/minimal_allocator.cpp ;
run unordered/compile_set.cpp ;
run unordered/compile_map.cpp ;
run unordered/noexcept_tests.cpp ;
run unordered/link_test_1.cpp unordered/link_test_2.cpp ;
run unordered/incomplete_test.cpp ;
run unordered/simple_tests.cpp ;
run unordered/equivalent_keys_tests.cpp ;
run unordered/constructor_tests.cpp ;
run unordered/copy_tests.cpp ;
run unordered/move_tests.cpp ;
run unordered/post_move_tests.cpp ;
run unordered/assign_tests.cpp ;
run unordered/insert_tests.cpp ;
run unordered/insert_stable_tests.cpp ;
run unordered/insert_hint_tests.cpp ;
run unordered/emplace_tests.cpp ;
run unordered/unnecessary_copy_tests.cpp ;
run unordered/erase_tests.cpp : : : <define>BOOST_UNORDERED_SUPPRESS_DEPRECATED ;
run unordered/erase_equiv_tests.cpp ;
run unordered/extract_tests.cpp ;
run unordered/node_handle_tests.cpp ;
run unordered/merge_tests.cpp ;
compile-fail unordered/insert_node_type_fail.cpp : <define>UNORDERED_TEST_MAP : insert_node_type_fail_map ;
compile-fail unordered/insert_node_type_fail.cpp : <define>UNORDERED_TEST_MULTIMAP : insert_node_type_fail_multimap ;
compile-fail unordered/insert_node_type_fail.cpp : <define>UNORDERED_TEST_SET : insert_node_type_fail_set ;
compile-fail unordered/insert_node_type_fail.cpp : <define>UNORDERED_TEST_MULTISET : insert_node_type_fail_multiset ;
run unordered/find_tests.cpp ;
run unordered/at_tests.cpp ;
run unordered/bucket_tests.cpp ;
run unordered/load_factor_tests.cpp ;
run unordered/rehash_tests.cpp ;
run unordered/equality_tests.cpp ;
run unordered/swap_tests.cpp ;
run unordered/deduction_tests.cpp ;
run unordered/scoped_allocator.cpp : : : <toolset>msvc-14.0:<build>no ;
run unordered/transparent_tests.cpp ;
run unordered/reserve_tests.cpp ;
run unordered/contains_tests.cpp ;
run unordered/erase_if.cpp ;
run unordered/scary_tests.cpp ;

run unordered/compile_set.cpp : : : <define>BOOST_UNORDERED_USE_MOVE : bmove_compile_set ;
run unordered/compile_map.cpp : : : <define>BOOST_UNORDERED_USE_MOVE : bmove_compile_map ;
run unordered/copy_tests.cpp : : : <define>BOOST_UNORDERED_USE_MOVE : bmove_copy ;
run unordered/move_tests.cpp : : : <define>BOOST_UNORDERED_USE_MOVE : bmove_move ;
run unordered/assign_tests.cpp : : : <define>BOOST_UNORDERED_USE_MOVE : bmove_assign ;


run exception/constructor_exception_tests.cpp ;
run exception/copy_exception_tests.cpp ;
run exception/assign_exception_tests.cpp ;
run exception/move_assign_exception_tests.cpp ;
run exception/insert_exception_tests.cpp ;
run exception/erase_exception_tests.cpp ;
run exception/rehash_exception_tests.cpp ;
run exception/swap_exception_tests.cpp : : : <define>BOOST_UNORDERED_SWAP_METHOD=2 ;
run exception/merge_exception_tests.cpp ;
run exception/less_tests.cpp ;

run unordered/narrow_cast_tests.cpp ;
run quick.cpp ;

import ../../config/checks/config : requires ;

CPP11 = [ requires cxx11_constexpr cxx11_noexcept cxx11_decltype cxx11_alignas ] ;

local FOA_TESTS =
  fwd_set_test
  fwd_map_test
  compile_set
  compile_map
  noexcept_tests
  incomplete_test
  simple_tests
  equivalent_keys_tests
  constructor_tests
  copy_tests
  move_tests
  post_move_tests
  assign_tests
  insert_tests
  insert_hint_tests
  emplace_tests
  erase_tests
  merge_tests
  find_tests
  at_tests
  load_factor_tests
  rehash_tests
  equality_tests
  swap_tests
  transparent_tests
  reserve_tests
  contains_tests
  erase_if
  scary_tests
  init_type_insert_tests
  max_load_tests
  extract_tests
  node_handle_tests
  uses_allocator
;

for local test in $(FOA_TESTS)
{
  run unordered/$(test).cpp : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_$(test) ;
}

run unordered/link_test_1.cpp unordered/link_test_2.cpp : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_link_test ;
run unordered/scoped_allocator.cpp : : : $(CPP11) <toolset>msvc-14.0:<build>no <define>BOOST_UNORDERED_FOA_TESTS : foa_scoped_allocator ;
run unordered/hash_is_avalanching_test.cpp ;
run exception/constructor_exception_tests.cpp : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_constructor_exception_tests ;
run exception/copy_exception_tests.cpp        : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_copy_exception_tests ;
run exception/assign_exception_tests.cpp      : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_assign_exception_tests ;
run exception/move_assign_exception_tests.cpp : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_move_assign_exception_tests ;
run exception/insert_exception_tests.cpp      : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_insert_exception_tests ;
run exception/erase_exception_tests.cpp       : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_erase_exception_tests ;
run exception/rehash_exception_tests.cpp      : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_rehash_exception_tests ;
run exception/swap_exception_tests.cpp        : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_swap_exception_tests ;
run exception/merge_exception_tests.cpp       : : : $(CPP11) <define>BOOST_UNORDERED_FOA_TESTS : foa_merge_exception_tests ;

alias foa_tests :
  foa_$(FOA_TESTS)
  foa_link_test
  foa_scoped_allocator
  hash_is_avalanching_test
  foa_constructor_exception_tests
  foa_copy_exception_tests
  foa_assign_exception_tests
  foa_move_assign_exception_tests
  foa_insert_exception_tests
  foa_erase_exception_tests
  foa_rehash_exception_tests
  foa_swap_exception_tests
  foa_merge_exception_tests
;

local CFOA_TESTS =
  latch_tests
  insert_tests
  erase_tests
  try_emplace_tests
  emplace_tests
  visit_tests
  constructor_tests
  assign_tests
  clear_tests
  swap_tests
  merge_tests
  rehash_tests
;

for local test in $(CFOA_TESTS)
{
  run cfoa/$(test).cpp
  : requirements $(CPP11)
  : target-name cfoa_$(test)
  ;
}

alias cfoa_tests : cfoa_$(CFOA_TESTS) ;
