Skip to content

Commit

Permalink
enable test that should only be disabled on MSVC Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Werner Henze committed Dec 30, 2024
1 parent 3db295e commit b8d31b2
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions tests/span_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ TEST(span_test, from_pointer_length_constructor)

TEST(span_test, from_pointer_pointer_construction)
{
#if !defined(_MSVC_STL_VERSION) || !defined(_NDEBUG)
const auto terminateHandler = std::set_terminate([] {
std::cerr << "Expected Death. from_pointer_pointer_construction";
std::abort();
});
const auto expected = GetExpectedDeathString(terminateHandler);
#endif

int arr[4] = {1, 2, 3, 4};

{
Expand Down Expand Up @@ -244,18 +252,20 @@ TEST(span_test, from_pointer_pointer_construction)
EXPECT_TRUE(s.data() == &arr[0]);
}

#if !defined(_MSVC_STL_VERSION) || !defined(_NDEBUG)
// this will fail the std::distance() precondition, which asserts on MSVC debug builds
//{
// auto workaround_macro = [&]() { span<int> s{&arr[1], &arr[0]}; };
// EXPECT_DEATH(workaround_macro(), expected);
//}
{
auto workaround_macro = [&]() { span<int> s{&arr[1], &arr[0]}; };
EXPECT_DEATH(workaround_macro(), expected);
}

// this will fail the std::distance() precondition, which asserts on MSVC debug builds
//{
// int* p = nullptr;
// auto workaround_macro = [&]() { span<int> s{&arr[0], p}; };
// EXPECT_DEATH(workaround_macro(), expected);
//}
{
int* p = nullptr;
auto workaround_macro = [&]() { span<int> s{&arr[0], p}; };
EXPECT_DEATH(workaround_macro(), expected);
}
#endif

{
int* p = nullptr;
Expand All @@ -271,12 +281,14 @@ TEST(span_test, from_pointer_pointer_construction)
EXPECT_TRUE(s.data() == nullptr);
}

#if !defined(_MSVC_STL_VERSION) || !defined(_NDEBUG)
// this will fail the std::distance() precondition, which asserts on MSVC debug builds
//{
// int* p = nullptr;
// auto workaround_macro = [&]() { span<int> s{&arr[0], p}; };
// EXPECT_DEATH(workaround_macro(), expected);
//}
{
int* p = nullptr;
auto workaround_macro = [&]() { span<int> s{&arr[0], p}; };
EXPECT_DEATH(workaround_macro(), expected);
}
#endif
}

TEST(span_test, from_array_constructor)
Expand Down

0 comments on commit b8d31b2

Please sign in to comment.