From 5a1fb8e18457ef08e22175ba12e9f61553db2436 Mon Sep 17 00:00:00 2001 From: Werner Henze Date: Wed, 18 Dec 2024 21:10:23 +0100 Subject: [PATCH] this commits adds tests that should fail, but don't --- tests/byte_tests.cpp | 39 +++++++++++++++++++++++++++++++++++++++ tests/pointers_tests.cpp | 21 +++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/tests/byte_tests.cpp b/tests/byte_tests.cpp index 1d2052a..0308992 100644 --- a/tests/byte_tests.cpp +++ b/tests/byte_tests.cpp @@ -19,6 +19,9 @@ #define GSL_USE_STD_BYTE 0 #include // for to_byte, to_integer, byte, operator&, ope... +#include +#include + using namespace std; using namespace gsl; @@ -128,6 +131,42 @@ TEST(byte_tests, aliasing) EXPECT_TRUE(res == i); } +// These are regressions, should be fixed. +template +static constexpr bool LShiftCompilesFor = false; +template +static constexpr bool LShiftCompilesFor< + U, std::void_t(declval(), declval()))>> = true; +static_assert(LShiftCompilesFor, "LShiftCompilesFor"); + +template +static constexpr bool RShiftCompilesFor = false; +template +static constexpr bool RShiftCompilesFor< + U, std::void_t> (declval(), declval()))>> = true; +static_assert(RShiftCompilesFor, "RShiftCompilesFor"); + +template +static constexpr bool LShiftAssignCompilesFor = false; +template +static constexpr bool LShiftAssignCompilesFor< + U, std::void_t(declval(), declval()))>> = true; +static_assert(LShiftAssignCompilesFor, "LShiftAssignCompilesFor"); + +template +static constexpr bool RShiftAssignCompilesFor = false; +template +static constexpr bool RShiftAssignCompilesFor< + U, std::void_t>= (declval(), declval()))>> = true; +static_assert(RShiftAssignCompilesFor, "RShiftAssignCompilesFor"); + +template +static constexpr bool ToIntegerCompilesFor = false; +template +static constexpr bool ToIntegerCompilesFor< + U, std::void_t(gsl::byte{}))>> = true; +static_assert(ToIntegerCompilesFor, "ToIntegerCompilesFor"); + } // namespace #ifdef CONFIRM_COMPILATION_ERRORS diff --git a/tests/pointers_tests.cpp b/tests/pointers_tests.cpp index fc9fb45..cbb476b 100644 --- a/tests/pointers_tests.cpp +++ b/tests/pointers_tests.cpp @@ -3,6 +3,11 @@ #include #include +#include +#include + +namespace +{ TEST(pointers_test, swap) { @@ -19,3 +24,19 @@ TEST(pointers_test, swap) EXPECT_TRUE(*b == 0); } +// These are regressions, should be fixed. +struct NotMovable +{ + NotMovable(NotMovable&&) = delete; + NotMovable& operator=(NotMovable&&) = delete; +}; +template +static constexpr bool SwapCompilesFor = false; +template +static constexpr bool SwapCompilesFor< + U, std::void_t(std::declval&>(), + std::declval&>()))>> = + true; +static_assert(SwapCompilesFor, "SwapCompilesFor"); + +} // namespace