gsl::at behavior change regarding gsl::span (#985)

* move span specialization of 'at' to <gsl/span> and update the parameter to be taken by reference

* undid previous changes and acted upon decisions made in maintainer sync. Fixed tests failing in /kernel mode

* ran clang-format on the include folder

* ran clang-format on the test folder

Co-authored-by: Jordan Maples <jordan.maples@microsoft.com>
This commit is contained in:
Jordan Maples [MSFT]
2021-05-20 18:18:08 -07:00
committed by GitHub
parent c1cbb41b42
commit b26f6d5ec7
20 changed files with 1304 additions and 1175 deletions

View File

@@ -14,16 +14,13 @@
//
///////////////////////////////////////////////////////////////////////////////
#include <gtest/gtest.h>
#include <array> // for array
#include <cstddef> // for size_t
#include <gsl/algorithm> // for copy
#include <gsl/span> // for span
#include <array> // for array
#include <cstddef> // for size_t
#include <gsl/span> // for span
#include <gtest/gtest.h>
namespace
{
static constexpr char deathstring[] = "Expected Death";
}
#include "deathTestCommon.h"
namespace gsl
{
@@ -204,10 +201,11 @@ TEST(algorithm_tests, incompatible_type)
TEST(algorithm_tests, small_destination_span)
{
std::set_terminate([] {
const auto terminateHandler = std::set_terminate([] {
std::cerr << "Expected Death. small_destination_span";
std::abort();
});
const auto expected = GetExpectedDeathString(terminateHandler);
std::array<int, 12> src{1, 2, 3, 4};
std::array<int, 4> dst{};
@@ -217,9 +215,9 @@ TEST(algorithm_tests, small_destination_span)
const span<int> dst_span_dyn(dst);
const span<int, 4> dst_span_static(dst);
EXPECT_DEATH(copy(src_span_dyn, dst_span_dyn), deathstring);
EXPECT_DEATH(copy(src_span_dyn, dst_span_static), deathstring);
EXPECT_DEATH(copy(src_span_static, dst_span_dyn), deathstring);
EXPECT_DEATH(copy(src_span_dyn, dst_span_dyn), expected);
EXPECT_DEATH(copy(src_span_dyn, dst_span_static), expected);
EXPECT_DEATH(copy(src_span_static, dst_span_dyn), expected);
#ifdef CONFIRM_COMPILATION_ERRORS
copy(src_span_static, dst_span_static);