summaryrefslogtreecommitdiffstats
path: root/googletest/test/gtest_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/test/gtest_unittest.cc')
-rw-r--r--googletest/test/gtest_unittest.cc53
1 files changed, 21 insertions, 32 deletions
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index d90fee9..d17a155 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -55,11 +55,11 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
EXPECT_TRUE(dummy || !dummy); // Suppresses warning that dummy is unused.
}
+#include <limits.h> // For INT_MAX.
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <limits>
#include <map>
#include <ostream>
#include <type_traits>
@@ -233,7 +233,6 @@ using testing::internal::AppendUserMessage;
using testing::internal::ArrayAwareFind;
using testing::internal::ArrayEq;
using testing::internal::CodePointToUtf8;
-using testing::internal::CompileAssertTypesEqual;
using testing::internal::CopyArray;
using testing::internal::CountIf;
using testing::internal::EqFailure;
@@ -2168,12 +2167,12 @@ static Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ =
// First, some predicates and predicate-formatters needed by the tests.
-// Returns true if the argument is an even number.
+// Returns true if and only if the argument is an even number.
bool IsEven(int n) {
return (n % 2) == 0;
}
-// A functor that returns true if the argument is an even number.
+// A functor that returns true if and only if the argument is an even number.
struct IsEvenFunctor {
bool operator()(int n) { return IsEven(n); }
};
@@ -2217,13 +2216,13 @@ struct AssertIsEvenFunctor {
}
};
-// Returns true if the sum of the arguments is an even number.
+// Returns true if and only if the sum of the arguments is an even number.
bool SumIsEven2(int n1, int n2) {
return IsEven(n1 + n2);
}
-// A functor that returns true if the sum of the arguments is an even
-// number.
+// A functor that returns true if and only if the sum of the arguments is an
+// even number.
struct SumIsEven3Functor {
bool operator()(int n1, int n2, int n3) {
return IsEven(n1 + n2 + n3);
@@ -3953,11 +3952,11 @@ enum {
// On Linux, kCaseB and kCaseA have the same value when truncated to
// int size. We want to test whether this will confuse the
// assertions.
- kCaseB = std::numeric_limits<std::intmax_t>::max(),
+ kCaseB = testing::internal::kMaxBiggestInt,
# else
- kCaseB = std::numeric_limits<int>::max(),
+ kCaseB = INT_MAX,
# endif // GTEST_OS_LINUX
@@ -5344,7 +5343,7 @@ TEST_P(CodeLocationForTESTP, Verify) {
VERIFY_CODE_LOCATION;
}
-INSTANTIATE_TEST_SUITE_P(, CodeLocationForTESTP, Values(0));
+INSTANTIATE_TEST_SUITE_P(All, CodeLocationForTESTP, Values(0));
template <typename T>
class CodeLocationForTYPEDTEST : public Test {
@@ -6171,7 +6170,7 @@ TEST_F(ParseFlagsTest, WideStrings) {
#if GTEST_USE_OWN_FLAGFILE_FLAG_
class FlagfileTest : public ParseFlagsTest {
public:
- virtual void SetUp() {
+ void SetUp() override {
ParseFlagsTest::SetUp();
testdata_path_.Set(internal::FilePath(
@@ -6181,7 +6180,7 @@ class FlagfileTest : public ParseFlagsTest {
EXPECT_TRUE(testdata_path_.CreateFolder());
}
- virtual void TearDown() {
+ void TearDown() override {
testing::internal::posix::RmDir(testdata_path_.c_str());
ParseFlagsTest::TearDown();
}
@@ -7102,18 +7101,12 @@ TEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) {
EXPECT_FALSE(IsAProtocolMessage<const ConversionHelperBase>::value);
}
-// Tests that CompileAssertTypesEqual compiles when the type arguments are
-// equal.
-TEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) {
- CompileAssertTypesEqual<void, void>();
- CompileAssertTypesEqual<int*, int*>();
-}
-
// Tests GTEST_REMOVE_REFERENCE_AND_CONST_.
template <typename T1, typename T2>
void TestGTestRemoveReferenceAndConst() {
- CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>();
+ static_assert(std::is_same<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>::value,
+ "GTEST_REMOVE_REFERENCE_AND_CONST_ failed.");
}
TEST(RemoveReferenceToConstTest, Works) {
@@ -7128,7 +7121,8 @@ TEST(RemoveReferenceToConstTest, Works) {
template <typename T1, typename T2>
void TestGTestReferenceToConst() {
- CompileAssertTypesEqual<T1, GTEST_REFERENCE_TO_CONST_(T2)>();
+ static_assert(std::is_same<T1, GTEST_REFERENCE_TO_CONST_(T2)>::value,
+ "GTEST_REFERENCE_TO_CONST_ failed.");
}
TEST(GTestReferenceToConstTest, Works) {
@@ -7359,20 +7353,15 @@ TEST(IndexSequence, MakeIndexSequence) {
// ElemFromList
TEST(ElemFromList, Basic) {
using testing::internal::ElemFromList;
- using Idx = testing::internal::MakeIndexSequence<3>::type;
- EXPECT_TRUE((
- std::is_same<int, ElemFromList<0, Idx, int, double, char>::type>::value));
EXPECT_TRUE(
- (std::is_same<double,
- ElemFromList<1, Idx, int, double, char>::type>::value));
+ (std::is_same<int, ElemFromList<0, int, double, char>::type>::value));
EXPECT_TRUE(
- (std::is_same<char,
- ElemFromList<2, Idx, int, double, char>::type>::value));
+ (std::is_same<double, ElemFromList<1, int, double, char>::type>::value));
EXPECT_TRUE(
- (std::is_same<
- char, ElemFromList<7, testing::internal::MakeIndexSequence<12>::type,
- int, int, int, int, int, int, int, char, int, int,
- int, int>::type>::value));
+ (std::is_same<char, ElemFromList<2, int, double, char>::type>::value));
+ EXPECT_TRUE((
+ std::is_same<char, ElemFromList<7, int, int, int, int, int, int, int,
+ char, int, int, int, int>::type>::value));
}
// FlatTuple