diff options
| author | Martin Hořeňovský | 2023-10-28 21:49:49 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2023-10-28 21:49:58 +0200 |
| commit | 79d39a1954837f234b48e3bc342b7f26e535d8a5 (patch) | |
| tree | d2dbaebaf8977cd40096ae903742248276d7d50f /tests/SelfTest/UsageTests/Message.tests.cpp | |
| parent | 6ebc013b8cfe438a3a397817ad662db34a978238 (diff) | |
| download | catch3-79d39a1954837f234b48e3bc342b7f26e535d8a5.tar.gz | |
Fix tests for C++23's multi-arg index operator
Closes #2744
Diffstat (limited to 'tests/SelfTest/UsageTests/Message.tests.cpp')
| -rw-r--r-- | tests/SelfTest/UsageTests/Message.tests.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/SelfTest/UsageTests/Message.tests.cpp b/tests/SelfTest/UsageTests/Message.tests.cpp index 419c5372..6367bf59 100644 --- a/tests/SelfTest/UsageTests/Message.tests.cpp +++ b/tests/SelfTest/UsageTests/Message.tests.cpp @@ -255,10 +255,24 @@ std::ostream& operator<<(std::ostream& out, helper_1436<T1, T2> const& helper) { #pragma clang diagnostic ignored "-Wunused-value" #endif +namespace { + template <typename T> + struct custom_index_op { + constexpr custom_index_op( std::initializer_list<T> ) {} + constexpr T operator[]( size_t ) { return T{}; } +#if defined( __cpp_multidimensional_subscript ) && \ + __cpp_multidimensional_subscript >= 202110L + constexpr T operator[]( size_t, size_t, size_t ) const noexcept { + return T{}; + } +#endif + }; +} + TEST_CASE("CAPTURE can deal with complex expressions involving commas", "[messages][capture]") { - CAPTURE(std::vector<int>{1, 2, 3}[0, 1, 2], - std::vector<int>{1, 2, 3}[(0, 1)], - std::vector<int>{1, 2, 3}[0]); + CAPTURE(custom_index_op<int>{1, 2, 3}[0, 1, 2], + custom_index_op<int>{1, 2, 3}[(0, 1)], + custom_index_op<int>{1, 2, 3}[0]); CAPTURE((helper_1436<int, int>{12, -12}), (helper_1436<int, int>(-12, 12))); CAPTURE( (1, 2), (2, 3) ); |