ignore warnings from gtest

This commit is contained in:
Jordan Maples [MSFT] 2019-12-04 12:30:58 -08:00
parent 603b4671c1
commit 43aca2646b
13 changed files with 148 additions and 12 deletions

View File

@ -20,6 +20,13 @@
#pragma warning(disable : 26440 26426) // from catch #pragma warning(disable : 26440 26426) // from catch
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gsl/gsl_algorithm> // for copy #include <gsl/gsl_algorithm> // for copy
@ -214,3 +221,7 @@ TEST(algorithm_tests, small_destination_span)
copy(src_span_static, dst_span_static); copy(src_span_static, dst_span_static);
#endif #endif
} }
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -20,6 +20,14 @@
#pragma warning(disable : 26440 26426) // from catch #pragma warning(disable : 26440 26426) // from catch
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gsl/gsl_assert> // for fail_fast (ptr only), Ensures, Expects #include <gsl/gsl_assert> // for fail_fast (ptr only), Ensures, Expects
@ -54,3 +62,7 @@ TEST(assertion_tests, ensures)
EXPECT_EQ(g(2), 3); EXPECT_EQ(g(2), 3);
EXPECT_DEATH(g(9), ".*"); EXPECT_DEATH(g(9), ".*");
} }
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -20,6 +20,14 @@
#pragma warning(disable : 26440 26426) // from catch #pragma warning(disable : 26440 26426) // from catch
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gsl/gsl_util> // for at #include <gsl/gsl_util> // for at
@ -115,3 +123,6 @@ static constexpr bool test_constexpr()
static_assert(test_constexpr(), "FAIL"); static_assert(test_constexpr(), "FAIL");
#endif #endif
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -24,6 +24,11 @@
#if __clang__ || __GNUC__ #if __clang__ || __GNUC__
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
//disable warnings from gtest
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif #endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
@ -96,8 +101,6 @@ TEST(bounds_tests, bounds_convertible)
static_bounds<7, 4, 2> b4 = b3; static_bounds<7, 4, 2> b4 = b3;
(void) b4; (void) b4;
static_bounds<dynamic_range> b11;
static_bounds<dynamic_range> b5; static_bounds<dynamic_range> b5;
static_bounds<34> b6; static_bounds<34> b6;

View File

@ -20,6 +20,14 @@
#pragma warning(disable : 26440 26426) // from catch #pragma warning(disable : 26440 26426) // from catch
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gsl/gsl_byte> // for to_byte, to_integer, byte, operator&, ope... #include <gsl/gsl_byte> // for to_byte, to_integer, byte, operator&, ope...
@ -133,3 +141,7 @@ TEST(byte_tests, aliasing)
#ifdef CONFIRM_COMPILATION_ERRORS #ifdef CONFIRM_COMPILATION_ERRORS
copy(src_span_static, dst_span_static); copy(src_span_static, dst_span_static);
#endif #endif
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -25,6 +25,12 @@
#if __clang__ || __GNUC__ #if __clang__ || __GNUC__
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
//disable warnings from gtest
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif #endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
@ -1033,18 +1039,18 @@ TEST(multi_span_test, rank)
{ {
multi_span<int> s; multi_span<int> s;
EXPECT_EQ(s.rank(), 1); EXPECT_EQ(s.rank(), static_cast<size_t>(1));
} }
{ {
multi_span<int, 2> s = arr; multi_span<int, 2> s = arr;
EXPECT_EQ(s.rank(), 1); EXPECT_EQ(s.rank(), static_cast<size_t>(1));
} }
int arr2d[1][1] = {}; int arr2d[1][1] = {};
{ {
multi_span<int, 1, 1> s = arr2d; multi_span<int, 1, 1> s = arr2d;
EXPECT_EQ(s.rank(), 2); EXPECT_EQ(s.rank(), static_cast<size_t>(2));
} }
} }

View File

@ -23,6 +23,14 @@
#pragma warning(disable : 4702) // unreachable code #pragma warning(disable : 4702) // unreachable code
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gsl/pointers> // for not_null, operator<, operator<=, operator> #include <gsl/pointers> // for not_null, operator<, operator<=, operator>
@ -527,3 +535,7 @@ TEST(notnull_tests, TestMakeNotNull)
static_assert(std::is_nothrow_move_constructible<not_null<void*>>::value, static_assert(std::is_nothrow_move_constructible<not_null<void*>>::value,
"not_null must be no-throw move constructible"); "not_null must be no-throw move constructible");
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -21,6 +21,14 @@
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gsl/pointers> // for owner #include <gsl/pointers> // for owner
@ -48,3 +56,7 @@ TEST(owner_tests, check_pointer_constraint)
} }
#endif #endif
} }
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -21,6 +21,14 @@
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gsl/gsl_byte> // for byte #include <gsl/gsl_byte> // for byte
#include <gsl/gsl_util> // for narrow_cast, at #include <gsl/gsl_util> // for narrow_cast, at
#include <gsl/span> // for span, span_iterator, operator==, operator!= #include <gsl/span> // for span, span_iterator, operator==, operator!=
@ -1548,3 +1556,7 @@ TEST(span_test, from_array_constructor)
EXPECT_TRUE((std::is_default_constructible<span<int, 0>>::value)); EXPECT_TRUE((std::is_default_constructible<span<int, 0>>::value));
EXPECT_FALSE((std::is_default_constructible<span<int, 42>>::value)); EXPECT_FALSE((std::is_default_constructible<span<int, 42>>::value));
} }
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -23,6 +23,14 @@
#pragma warning(disable : 4702) // unreachable code #pragma warning(disable : 4702) // unreachable code
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gsl/pointers> // for not_null, operator<, operator<=, operator> #include <gsl/pointers> // for not_null, operator<, operator<=, operator>
@ -191,3 +199,7 @@ TEST(strict_notnull_tests, TestStrictNotNullConstructorTypeDeduction)
static_assert(std::is_nothrow_move_constructible<strict_not_null<void*>>::value, static_assert(std::is_nothrow_move_constructible<strict_not_null<void*>>::value,
"strict_not_null must be no-throw move constructible"); "strict_not_null must be no-throw move constructible");
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -25,6 +25,11 @@
#if __clang__ || __GNUC__ #if __clang__ || __GNUC__
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
//disable warnings from gtest
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif #endif
#include <gtest/gtest.h> #include <gtest/gtest.h>

View File

@ -21,6 +21,14 @@
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gsl/gsl_assert> // for Expects, fail_fast (ptr only) #include <gsl/gsl_assert> // for Expects, fail_fast (ptr only)
@ -68,6 +76,9 @@ T move_wrapper(T&& t)
return std::move(t); return std::move(t);
} }
// not used otherwise
#ifdef CONFIRM_COMPILATION_ERRORS
template <class T> template <class T>
T create() T create()
{ {
@ -78,6 +89,7 @@ template <class T>
void use(basic_string_span<T, gsl::dynamic_extent>) void use(basic_string_span<T, gsl::dynamic_extent>)
{ {
} }
#endif
czstring_span<> CreateTempName(string_span<> span) czstring_span<> CreateTempName(string_span<> span)
{ {
@ -226,26 +238,26 @@ TEST(string_span_tests, TestConversionFromConst)
TEST(string_span_tests, TestToString) TEST(string_span_tests, TestToString)
{ {
auto s = gsl::to_string(cstring_span<>{}); auto s = gsl::to_string(cstring_span<>{});
EXPECT_EQ(s.length(), 0); EXPECT_EQ(s.length(), static_cast<size_t>(0));
char stack_string[] = "Hello"; char stack_string[] = "Hello";
cstring_span<> v = ensure_z(stack_string); cstring_span<> v = ensure_z(stack_string);
auto s2 = gsl::to_string(v); auto s2 = gsl::to_string(v);
EXPECT_EQ(static_cast<cstring_span<>::index_type>(s2.length()), v.length()); EXPECT_EQ(static_cast<cstring_span<>::index_type>(s2.length()), v.length());
EXPECT_EQ(s2.length(), 5); EXPECT_EQ(s2.length(), static_cast<size_t>(5));
} }
TEST(string_span_tests, TestToBasicString) TEST(string_span_tests, TestToBasicString)
{ {
auto s = gsl::to_basic_string<char, std::char_traits<char>, ::std::allocator<char>>( auto s = gsl::to_basic_string<char, std::char_traits<char>, ::std::allocator<char>>(
cstring_span<>{}); cstring_span<>{});
EXPECT_EQ(s.length(), 0); EXPECT_EQ(s.length(), static_cast<size_t>(0));
char stack_string[] = "Hello"; char stack_string[] = "Hello";
cstring_span<> v = ensure_z(stack_string); cstring_span<> v = ensure_z(stack_string);
auto s2 = gsl::to_basic_string<char, std::char_traits<char>, ::std::allocator<char>>(v); auto s2 = gsl::to_basic_string<char, std::char_traits<char>, ::std::allocator<char>>(v);
EXPECT_EQ(static_cast<cstring_span<>::index_type>(s2.length()), v.length()); EXPECT_EQ(static_cast<cstring_span<>::index_type>(s2.length()), v.length());
EXPECT_EQ(s2.length(), 5); EXPECT_EQ(s2.length(), static_cast<size_t>(5));
} }
TEST(string_span_tests, EqualityAndImplicitConstructors) TEST(string_span_tests, EqualityAndImplicitConstructors)
@ -1198,3 +1210,7 @@ TEST(string_span_tests, as_writeable_bytes)
EXPECT_EQ(static_cast<const void*>(bs.data()), static_cast<const void*>(s.data())); EXPECT_EQ(static_cast<const void*>(bs.data()), static_cast<const void*>(s.data()));
EXPECT_EQ(bs.size(), s.size_bytes()); EXPECT_EQ(bs.size(), s.size_bytes());
} }
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -21,6 +21,14 @@
#endif #endif
#if __clang__ || __GNUC__
//disable warnings from gtest
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wglobal-constructors"
#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#pragma GCC diagnostic ignored "-Wcovered-switch-default"
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gsl/gsl_util> // for narrow, finally, narrow_cast, narrowing_e... #include <gsl/gsl_util> // for narrow, finally, narrow_cast, narrowing_e...
@ -130,3 +138,7 @@ TEST(utils_tests, narrow)
#endif #endif
} }
#if __clang__ || __GNUC__
#pragma GCC diagnostic pop
#endif