mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
add some span test for constructor from other span (#1093)
More combinations with dynamic_extent or fixed extent for higher coverage.
This commit is contained in:
parent
743939744c
commit
9851b94d7e
@ -646,37 +646,93 @@ TEST(span_test, from_container_constructor)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(span_test, from_convertible_span_constructor){{span<DerivedClass> avd;
|
||||
span<const DerivedClass> avcd = avd;
|
||||
static_cast<void>(avcd);
|
||||
}
|
||||
|
||||
TEST(span_test, from_convertible_span_constructor)
|
||||
{
|
||||
const auto terminateHandler = std::set_terminate([] {
|
||||
std::cerr << "Expected Death. from_convertible_span_constructor";
|
||||
std::abort();
|
||||
});
|
||||
const auto expected = GetExpectedDeathString(terminateHandler);
|
||||
|
||||
{
|
||||
span<DerivedClass> avd;
|
||||
span<const DerivedClass> avcd = avd;
|
||||
static_cast<void>(avcd);
|
||||
}
|
||||
|
||||
{
|
||||
std::array<DerivedClass, 2> arr{};
|
||||
span<DerivedClass, 2> avd{arr};
|
||||
span<const DerivedClass, 2> avcd = avd;
|
||||
static_cast<void>(avcd);
|
||||
}
|
||||
|
||||
{
|
||||
std::array<DerivedClass, 2> arr{};
|
||||
span<DerivedClass, 2> avd{arr};
|
||||
span<const DerivedClass> avcd = avd;
|
||||
static_cast<void>(avcd);
|
||||
}
|
||||
|
||||
{
|
||||
std::array<DerivedClass, 2> arr{};
|
||||
span<DerivedClass> avd{arr};
|
||||
span<const DerivedClass, 2> avcd{avd};
|
||||
static_cast<void>(avcd);
|
||||
}
|
||||
|
||||
{
|
||||
std::array<DerivedClass, 1> arr{};
|
||||
span<DerivedClass> avd{arr};
|
||||
using T = span<const DerivedClass, 2>;
|
||||
EXPECT_DEATH(T{avd}, expected);
|
||||
}
|
||||
|
||||
#ifdef CONFIRM_COMPILATION_ERRORS
|
||||
{
|
||||
std::array<DerivedClass, 2> arr{};
|
||||
span<DerivedClass> avd{arr};
|
||||
span<const DerivedClass, 2> avcd = avd;
|
||||
static_cast<void>(avcd);
|
||||
}
|
||||
|
||||
{
|
||||
std::array<DerivedClass, 2> arr{};
|
||||
span<DerivedClass, 2> avd{arr};
|
||||
span<const DerivedClass, 1> avcd = avd;
|
||||
static_cast<void>(avcd);
|
||||
}
|
||||
|
||||
{
|
||||
std::array<DerivedClass, 2> arr{};
|
||||
span<DerivedClass, 2> avd{arr};
|
||||
span<const DerivedClass, 3> avcd = avd;
|
||||
static_cast<void>(avcd);
|
||||
}
|
||||
|
||||
{
|
||||
span<DerivedClass> avd;
|
||||
span<BaseClass> avb = avd;
|
||||
static_cast<void>(avb);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIRM_COMPILATION_ERRORS
|
||||
{
|
||||
{
|
||||
span<int> s;
|
||||
span<unsigned int> s2 = s;
|
||||
static_cast<void>(s2);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
span<int> s;
|
||||
span<const unsigned int> s2 = s;
|
||||
static_cast<void>(s2);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
span<int> s;
|
||||
span<short> s2 = s;
|
||||
static_cast<void>(s2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user