mirror of
https://github.com/microsoft/GSL.git
synced 2025-04-01 08:56:29 -04:00
this commits adds tests that should fail, but don't
This commit is contained in:
parent
b8ac820fe1
commit
5a1fb8e184
@ -19,6 +19,9 @@
|
||||
#define GSL_USE_STD_BYTE 0
|
||||
#include <gsl/byte> // for to_byte, to_integer, byte, operator&, ope...
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
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 <typename U, typename = void>
|
||||
static constexpr bool LShiftCompilesFor = false;
|
||||
template <typename U>
|
||||
static constexpr bool LShiftCompilesFor<
|
||||
U, std::void_t<decltype(gsl::operator<< <float, void>(declval<gsl::byte>(), declval<U>()))>> = true;
|
||||
static_assert(LShiftCompilesFor<float>, "LShiftCompilesFor<float>");
|
||||
|
||||
template <typename U, typename = void>
|
||||
static constexpr bool RShiftCompilesFor = false;
|
||||
template <typename U>
|
||||
static constexpr bool RShiftCompilesFor<
|
||||
U, std::void_t<decltype(gsl::operator>> <U, void>(declval<gsl::byte>(), declval<U>()))>> = true;
|
||||
static_assert(RShiftCompilesFor<float>, "RShiftCompilesFor<float>");
|
||||
|
||||
template <typename U, typename = void>
|
||||
static constexpr bool LShiftAssignCompilesFor = false;
|
||||
template <typename U>
|
||||
static constexpr bool LShiftAssignCompilesFor<
|
||||
U, std::void_t<decltype(gsl::operator<<= <U, void>(declval<gsl::byte&>(), declval<U>()))>> = true;
|
||||
static_assert(LShiftAssignCompilesFor<float>, "LShiftAssignCompilesFor<float>");
|
||||
|
||||
template <typename U, typename = void>
|
||||
static constexpr bool RShiftAssignCompilesFor = false;
|
||||
template <typename U>
|
||||
static constexpr bool RShiftAssignCompilesFor<
|
||||
U, std::void_t<decltype(gsl::operator>>= <U, void>(declval<gsl::byte&>(), declval<U>()))>> = true;
|
||||
static_assert(RShiftAssignCompilesFor<float>, "RShiftAssignCompilesFor<float>");
|
||||
|
||||
template <typename U, typename = void>
|
||||
static constexpr bool ToIntegerCompilesFor = false;
|
||||
template <typename U>
|
||||
static constexpr bool ToIntegerCompilesFor<
|
||||
U, std::void_t<decltype(gsl::to_integer<U, void>(gsl::byte{}))>> = true;
|
||||
static_assert(ToIntegerCompilesFor<float>, "ToIntegerCompilesFor<float>");
|
||||
|
||||
} // namespace
|
||||
|
||||
#ifdef CONFIRM_COMPILATION_ERRORS
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include <gsl/pointers>
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
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 <typename U, typename = void>
|
||||
static constexpr bool SwapCompilesFor = false;
|
||||
template <typename U>
|
||||
static constexpr bool SwapCompilesFor<
|
||||
U, std::void_t<decltype(gsl::swap<U, void>(std::declval<gsl::not_null<U>&>(),
|
||||
std::declval<gsl::not_null<U>&>()))>> =
|
||||
true;
|
||||
static_assert(SwapCompilesFor<NotMovable>, "SwapCompilesFor<NotMovable>");
|
||||
|
||||
} // namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user