diff options
author | Johel Ernesto Guerrero Peña <johelegp@gmail.com> | 2021-06-24 01:28:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-24 01:28:45 +0300 |
commit | 8a4b9ed0bf643726ce625678a17b1fc40d90870c (patch) | |
tree | 166001718f7fa975d62f6d3809c6c7553b157444 /tests | |
parent | b26f6d5ec7b043f9d459c1dfdd6da4d930d4e9b4 (diff) |
feat: narrow for non totally ordered types (#986)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/utils_tests.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index 0585c79..39b4ca2 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -17,6 +17,7 @@ #include <gtest/gtest.h> #include <algorithm> // for move +#include <complex> #include <cstddef> // for std::ptrdiff_t #include <functional> // for reference_wrapper, _Bind_helper<>::type #include <gsl/narrow> // for narrow, narrowing_error @@ -144,5 +145,9 @@ TEST(utils_tests, narrow) n = -42; EXPECT_THROW(narrow<unsigned>(n), narrowing_error); + + EXPECT_TRUE( + narrow<std::complex<float>>(std::complex<double>(4, 2)) == std::complex<float>(4, 2)); + EXPECT_THROW(narrow<std::complex<float>>(std::complex<double>(4.2)), narrowing_error); } #endif // GSL_KERNEL_MODE |