| 1 |
|
| 2 |
// Copyright Catch2 Authors |
| 3 |
// Distributed under the Boost Software License, Version 1.0. |
| 4 |
// (See accompanying file LICENSE.txt or copy at |
| 5 |
// https://www.boost.org/LICENSE_1_0.txt) |
| 6 |
|
| 7 |
// SPDX-License-Identifier: BSL-1.0 |
| 8 |
|
| 9 |
#include <catch2/catch_test_macros.hpp> |
| 10 |
#include <catch2/internal/catch_compare_traits.hpp> |
| 11 |
#include <helpers/type_with_lit_0_comparisons.hpp> |
| 12 |
|
| 13 |
|
| 14 |
#define ADD_TRAIT_TEST_CASE( op ) \ |
| 15 |
TEST_CASE( "is_" #op "_comparable", \ |
| 16 |
"[traits][is_comparable][approvals]" ) { \ |
| 17 |
using Catch::Detail::is_##op##_0_comparable; \ |
| 18 |
using Catch::Detail::is_##op##_comparable; \ |
| 19 |
\ |
| 20 |
STATIC_REQUIRE( is_##op##_comparable<int, int>::value ); \ |
| 21 |
STATIC_REQUIRE( \ |
| 22 |
is_##op##_comparable<std::string, std::string>::value ); \ |
| 23 |
STATIC_REQUIRE( !is_##op##_comparable<int, std::string>::value ); \ |
| 24 |
STATIC_REQUIRE( \ |
| 25 |
!is_##op##_comparable<TypeWithLit0Comparisons, int>::value ); \ |
| 26 |
STATIC_REQUIRE( \ |
| 27 |
!is_##op##_comparable<int, TypeWithLit0Comparisons>::value ); \ |
| 28 |
\ |
| 29 |
STATIC_REQUIRE( is_##op##_0_comparable<int>::value ); \ |
| 30 |
STATIC_REQUIRE( \ |
| 31 |
is_##op##_0_comparable<TypeWithLit0Comparisons>::value ); \ |
| 32 |
STATIC_REQUIRE( !is_##op##_0_comparable<std::string>::value ); \ |
| 33 |
\ |
| 34 |
/* This test fails with MSVC in permissive mode, because of course it does */ \ |
| 35 |
/* STATIC_REQUIRE( !is_##op##_0_comparable<int*>::value ); */ \ |
| 36 |
} |
| 37 |
|
| 38 |
ADD_TRAIT_TEST_CASE(lt) |
| 39 |
ADD_TRAIT_TEST_CASE(gt) |
| 40 |
ADD_TRAIT_TEST_CASE(le) |
| 41 |
ADD_TRAIT_TEST_CASE(ge) |
| 42 |
ADD_TRAIT_TEST_CASE(eq) |
| 43 |
ADD_TRAIT_TEST_CASE(ne) |
| 44 |
|
| 45 |
#undef ADD_TRAIT_TEST_CASE |