gtest migration

This commit is contained in:
Jordan Maples [MSFT]
2019-12-03 14:32:25 -08:00
parent 7e99e76c97
commit 2b10729386
17 changed files with 3453 additions and 3588 deletions
+24 -29
View File
@@ -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);