Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/GSL.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNicholas Londey <nicholas@londey.com>2020-04-22 03:09:13 +0300
committerNicholas Londey <nicholas@londey.com>2020-04-22 03:09:13 +0300
commit61534ca3adda0e214d6fb7dd9bc4173edb6e02d1 (patch)
treebdf6fc23ae35f6fc2fb5f66e923080de3d83753e /tests
parent9f6a9a5807ad0de9c9c5294ece20639a5538f485 (diff)
Changed implementation of gsl::narrow to throw gsl::narrowing_error
Implementation now behaves as described in the C++ Core Guidlines
Diffstat (limited to 'tests')
-rw-r--r--tests/utils_tests.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp
index f7f7ce3..98faf58 100644
--- a/tests/utils_tests.cpp
+++ b/tests/utils_tests.cpp
@@ -104,11 +104,6 @@ TEST(utils_tests, narrow_cast)
TEST(utils_tests, narrow)
{
- std::set_terminate([] {
- std::cerr << "Expected Death. narrow";
- std::abort();
- });
-
int n = 120;
const char c = narrow<char>(n);
EXPECT_TRUE(c == 120);
@@ -123,14 +118,13 @@ TEST(utils_tests, narrow)
EXPECT_TRUE(narrow<uint32_t>(int32_t(1)) == 1);
EXPECT_TRUE(narrow<uint32_t>(int32_max) == static_cast<uint32_t>(int32_max));
- EXPECT_DEATH(narrow<uint32_t>(int32_t(-1)), deathstring);
- EXPECT_DEATH(narrow<uint32_t>(int32_min), deathstring);
+ EXPECT_THROW(narrow<uint32_t>(int32_t(-1)), narrowing_error);
+ EXPECT_THROW(narrow<uint32_t>(int32_min), narrowing_error);
n = -42;
- EXPECT_DEATH(narrow<unsigned>(n), deathstring);
+ EXPECT_THROW(narrow<unsigned>(n), narrowing_error);
#if GSL_CONSTEXPR_NARROW
static_assert(narrow<char>(120) == 120, "Fix GSL_CONSTEXPR_NARROW");
#endif
-
}