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
diff options
context:
space:
mode:
authorJordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>2019-12-04 01:32:25 +0300
committerJordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>2019-12-04 01:32:25 +0300
commit2b10729386062479641951e822e4257066655863 (patch)
tree8a6888152a800ecee4d5be08ebaf08c6e31f8eff /tests/algorithm_tests.cpp
parent7e99e76c9761d0d0b0848b91f8648830670ee872 (diff)
gtest migration
Diffstat (limited to 'tests/algorithm_tests.cpp')
-rw-r--r--tests/algorithm_tests.cpp53
1 files changed, 24 insertions, 29 deletions
diff --git a/tests/algorithm_tests.cpp b/tests/algorithm_tests.cpp
index 368b53d..9345e95 100644
--- a/tests/algorithm_tests.cpp
+++ b/tests/algorithm_tests.cpp
@@ -20,7 +20,7 @@
#pragma warning(disable : 26440 26426) // from catch
#endif
-#include <catch/catch.hpp> // for AssertionHandler, StringRef, CHECK, CHE...
+#include <gtest/gtest.h>
#include <gsl/gsl_algorithm> // for copy
#include <gsl/span> // for span
@@ -35,9 +35,7 @@ struct fail_fast;
using namespace std;
using namespace gsl;
-GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
-GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute
-TEST_CASE("same_type")
+TEST(algorithm_tests, same_type)
{
// dynamic source and destination span
{
@@ -51,8 +49,8 @@ TEST_CASE("same_type")
copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) {
- CHECK(dst[i] == src[i]);
- CHECK(dst[i + src.size()] == src[i]);
+ EXPECT_EQ(dst[i], src[i]);
+ EXPECT_EQ(dst[i + src.size()], src[i]);
}
}
@@ -68,8 +66,8 @@ TEST_CASE("same_type")
copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) {
- CHECK(dst[i] == src[i]);
- CHECK(dst[i + src.size()] == src[i]);
+ EXPECT_EQ(dst[i], src[i]);
+ EXPECT_EQ(dst[i + src.size()], src[i]);
}
}
@@ -85,8 +83,8 @@ TEST_CASE("same_type")
copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) {
- CHECK(dst[i] == src[i]);
- CHECK(dst[i + src.size()] == src[i]);
+ EXPECT_EQ(dst[i], src[i]);
+ EXPECT_EQ(dst[i + src.size()], src[i]);
}
}
@@ -102,16 +100,13 @@ TEST_CASE("same_type")
copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) {
- CHECK(dst[i] == src[i]);
- CHECK(dst[i + src.size()] == src[i]);
+ EXPECT_EQ(dst[i], src[i]);
+ EXPECT_EQ(dst[i + src.size()], src[i]);
}
}
}
-
-GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute
-GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute
-TEST_CASE("compatible_type")
+TEST(algorithm_tests, compatible_type)
{
// dynamic source and destination span
{
@@ -125,8 +120,8 @@ TEST_CASE("compatible_type")
copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) {
- CHECK(dst[i] == src[i]);
- CHECK(dst[i + src.size()] == src[i]);
+ EXPECT_EQ(dst[i], src[i]);
+ EXPECT_EQ(dst[i + src.size()], src[i]);
}
}
@@ -142,8 +137,8 @@ TEST_CASE("compatible_type")
copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) {
- CHECK(dst[i] == src[i]);
- CHECK(dst[i + src.size()] == src[i]);
+ EXPECT_EQ(dst[i], src[i]);
+ EXPECT_EQ(dst[i + src.size()], src[i]);
}
}
@@ -159,8 +154,8 @@ TEST_CASE("compatible_type")
copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) {
- CHECK(dst[i] == src[i]);
- CHECK(dst[i + src.size()] == src[i]);
+ EXPECT_EQ(dst[i], src[i]);
+ EXPECT_EQ(dst[i + src.size()], src[i]);
}
}
@@ -176,14 +171,14 @@ TEST_CASE("compatible_type")
copy(src_span, dst_span.subspan(src_span.size()));
for (std::size_t i = 0; i < src.size(); ++i) {
- CHECK(dst[i] == src[i]);
- CHECK(dst[i + src.size()] == src[i]);
+ EXPECT_EQ(dst[i], src[i]);
+ EXPECT_EQ(dst[i + src.size()], src[i]);
}
}
}
#ifdef CONFIRM_COMPILATION_ERRORS
-TEST_CASE("incompatible_type")
+TEST(algorithm_tests, incompatible_type)
{
std::array<int, 4> src{1, 2, 3, 4};
std::array<int*, 12> dst{};
@@ -201,7 +196,7 @@ TEST_CASE("incompatible_type")
}
#endif
-TEST_CASE("small_destination_span")
+TEST(algorithm_tests, small_destination_span)
{
std::array<int, 12> src{1, 2, 3, 4};
std::array<int, 4> dst{};
@@ -211,9 +206,9 @@ TEST_CASE("small_destination_span")
const span<int> dst_span_dyn(dst);
const span<int, 4> dst_span_static(dst);
- CHECK_THROWS_AS(copy(src_span_dyn, dst_span_dyn), fail_fast);
- CHECK_THROWS_AS(copy(src_span_dyn, dst_span_static), fail_fast);
- CHECK_THROWS_AS(copy(src_span_static, dst_span_dyn), fail_fast);
+ EXPECT_DEATH(copy(src_span_dyn, dst_span_dyn), ".*");
+ EXPECT_DEATH(copy(src_span_dyn, dst_span_static), ".*");
+ EXPECT_DEATH(copy(src_span_static, dst_span_dyn), ".*");
#ifdef CONFIRM_COMPILATION_ERRORS
copy(src_span_static, dst_span_static);