import libassert = libassert%lib{assert}

libs = $libassert
import libs += \
  gtest%liba{gtest_main} \
  gmock%liba{gmock}

# Tests with own main() (no gtest dep):
#
for t : cxx{constexpr_contexts    \
            disambiguation        \
            literals              \
            test_public_utilities \
            test_type_prettier    \
            type_handling         \
           }
{
  n = $name($t)
  ./: exe{test-$n}: $t hxx{**} $libassert testscript
}

for t : cxx{* -std_format* -catch2-test \
              -assertion_tests \
              -constexpr_contexts \
              -disambiguation \
              -literals \
              -stringify \
              -test_public_utilities \
              -test_type_prettier \
              -type_handling \
           }
{
  n = $name($t)
  ./: exe{test-$n}: $t hxx{**} $libs testscript
}

exe{*}: test.arguments = --gtest_brief=1

# Upstream guard `_WIN32 && !LIBASSERT_IS_GCC` also fires for Clang (not clang-cl), which
# uses __PRETTY_FUNCTION__ and omits default template args like std::less<int>. Also,
# GCC 14+ made std::optional a range (P3168), which causes the container path to fire
# before the optional-specific path in libassert's stringification. Skip until fixed upstream.
#
./: exe{test-stringify}: \
  include = (!($cxx.id == 'clang' && $cxx.target.class == 'windows') && \
             !($cxx.id == 'gcc' && $cxx.version.major >= 14))
exe{test-stringify}: cxx{stringify} hxx{**} $libs testscript

# Same P3168 issue as above.
#
./: exe{test-assertion_tests}: \
  include = (!($cxx.id == 'gcc' && $cxx.version.major >= 14))
exe{test-assertion_tests}: cxx{assertion_tests} hxx{**} $libs testscript

# Upstream fmtable formatter uses concrete format_context&
# which std::formattable rejects on GCC/Clang.
#
./: exe{test-std_format20}: include = ($cxx.id == 'msvc')
exe{test-std_format20}: cxx{std_format20} hxx{**} $libs testscript
obj{std_format20}: cxx.mode = 20

# std::formattable not implemented for MSVC.
#
./: exe{test-std_format23}: include = ($cxx.id != 'msvc')
exe{test-std_format23}: cxx{std_format23} hxx{**} $libs testscript
obj{std_format23}: cxx.mode = 23

# Build options.
#
if ($cxx.class == 'msvc')
{
  cxx.coptions += /Zc:preprocessor
  obj{assertion_tests}: cxx.coptions += /permissive-
}
