This commit is contained in:
Hilman Beyri 2020-03-26 07:03:57 -04:00 committed by GitHub
commit e575187ddd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3020,13 +3020,13 @@ TEST(MatcherAssertionTest, WorksWhenMatcherIsNotSatisfied) {
EXPECT_FATAL_FAILURE(ASSERT_THAT(n, Gt(10)), EXPECT_FATAL_FAILURE(ASSERT_THAT(n, Gt(10)),
"Value of: n\n" "Value of: n\n"
"Expected: is > 10\n" "Expected: is > 10\n"
" Actual: 5" + OfType("unsigned short")); " Actual: 5" + OfType(internal::GetTypeName<unsigned short>()));
n = 0; n = 0;
EXPECT_NONFATAL_FAILURE( EXPECT_NONFATAL_FAILURE(
EXPECT_THAT(n, AllOf(Le(7), Ge(5))), EXPECT_THAT(n, AllOf(Le(7), Ge(5))),
"Value of: n\n" "Value of: n\n"
"Expected: (is <= 7) and (is >= 5)\n" "Expected: (is <= 7) and (is >= 5)\n"
" Actual: 0" + OfType("unsigned short")); " Actual: 0" + OfType(internal::GetTypeName<unsigned short>()));
} }
// Tests that ASSERT_THAT() and EXPECT_THAT() work when the argument // Tests that ASSERT_THAT() and EXPECT_THAT() work when the argument
@ -3042,7 +3042,7 @@ TEST(MatcherAssertionTest, WorksForByRefArguments) {
"Expected: does not reference the variable @"); "Expected: does not reference the variable @");
// Tests the "Actual" part. // Tests the "Actual" part.
EXPECT_FATAL_FAILURE(ASSERT_THAT(n, Not(Ref(n))), EXPECT_FATAL_FAILURE(ASSERT_THAT(n, Not(Ref(n))),
"Actual: 0" + OfType("int") + ", which is located @"); "Actual: 0" + OfType(internal::GetTypeName<int>()) + ", which is located @");
} }
// Tests that ASSERT_THAT() and EXPECT_THAT() work when the matcher is // Tests that ASSERT_THAT() and EXPECT_THAT() work when the matcher is
@ -3062,7 +3062,7 @@ TEST(MatcherAssertionTest, WorksForMonomorphicMatcher) {
EXPECT_NONFATAL_FAILURE(EXPECT_THAT(5, is_greater_than_5), EXPECT_NONFATAL_FAILURE(EXPECT_THAT(5, is_greater_than_5),
"Value of: 5\n" "Value of: 5\n"
"Expected: is > 5\n" "Expected: is > 5\n"
" Actual: 5" + OfType("int")); " Actual: 5" + OfType(internal::GetTypeName<int>()));
} }
// Tests floating-point matchers. // Tests floating-point matchers.
@ -3705,14 +3705,14 @@ TEST(PointeeTest, CanExplainMatchResult) {
const Matcher<long*> m2 = Pointee(GreaterThan(1)); // NOLINT const Matcher<long*> m2 = Pointee(GreaterThan(1)); // NOLINT
long n = 3; // NOLINT long n = 3; // NOLINT
EXPECT_EQ("which points to 3" + OfType("long") + ", which is 2 more than 1", EXPECT_EQ("which points to 3" + OfType(internal::GetTypeName<long>()) + ", which is 2 more than 1",
Explain(m2, &n)); Explain(m2, &n));
} }
TEST(PointeeTest, AlwaysExplainsPointee) { TEST(PointeeTest, AlwaysExplainsPointee) {
const Matcher<int*> m = Pointee(0); const Matcher<int*> m = Pointee(0);
int n = 42; int n = 42;
EXPECT_EQ("which points to 42" + OfType("int"), Explain(m, &n)); EXPECT_EQ("which points to 42" + OfType(internal::GetTypeName<int>()), Explain(m, &n));
} }
// An uncopyable class. // An uncopyable class.
@ -3871,11 +3871,11 @@ TEST(FieldTest, CanExplainMatchResult) {
AStruct a; AStruct a;
a.x = 1; a.x = 1;
EXPECT_EQ("whose given field is 1" + OfType("int"), Explain(m, a)); EXPECT_EQ("whose given field is 1" + OfType(internal::GetTypeName<int>()), Explain(m, a));
m = Field(&AStruct::x, GreaterThan(0)); m = Field(&AStruct::x, GreaterThan(0));
EXPECT_EQ( EXPECT_EQ(
"whose given field is 1" + OfType("int") + ", which is 1 more than 0", "whose given field is 1" + OfType(internal::GetTypeName<int>()) + ", which is 1 more than 0",
Explain(m, a)); Explain(m, a));
} }
@ -3884,10 +3884,10 @@ TEST(FieldTest, CanExplainMatchResultWithFieldName) {
AStruct a; AStruct a;
a.x = 1; a.x = 1;
EXPECT_EQ("whose field `field_name` is 1" + OfType("int"), Explain(m, a)); EXPECT_EQ("whose field `field_name` is 1" + OfType(internal::GetTypeName<int>()), Explain(m, a));
m = Field("field_name", &AStruct::x, GreaterThan(0)); m = Field("field_name", &AStruct::x, GreaterThan(0));
EXPECT_EQ("whose field `field_name` is 1" + OfType("int") + EXPECT_EQ("whose field `field_name` is 1" + OfType(internal::GetTypeName<int>()) +
", which is 1 more than 0", ", which is 1 more than 0",
Explain(m, a)); Explain(m, a));
} }
@ -3964,11 +3964,11 @@ TEST(FieldForPointerTest, CanExplainMatchResult) {
AStruct a; AStruct a;
a.x = 1; a.x = 1;
EXPECT_EQ("", Explain(m, static_cast<const AStruct*>(nullptr))); EXPECT_EQ("", Explain(m, static_cast<const AStruct*>(nullptr)));
EXPECT_EQ("which points to an object whose given field is 1" + OfType("int"), EXPECT_EQ("which points to an object whose given field is 1" + OfType(internal::GetTypeName<int>()),
Explain(m, &a)); Explain(m, &a));
m = Field(&AStruct::x, GreaterThan(0)); m = Field(&AStruct::x, GreaterThan(0));
EXPECT_EQ("which points to an object whose given field is 1" + OfType("int") + EXPECT_EQ("which points to an object whose given field is 1" + OfType(internal::GetTypeName<int>()) +
", which is 1 more than 0", Explain(m, &a)); ", which is 1 more than 0", Explain(m, &a));
} }
@ -3979,12 +3979,12 @@ TEST(FieldForPointerTest, CanExplainMatchResultWithFieldName) {
a.x = 1; a.x = 1;
EXPECT_EQ("", Explain(m, static_cast<const AStruct*>(nullptr))); EXPECT_EQ("", Explain(m, static_cast<const AStruct*>(nullptr)));
EXPECT_EQ( EXPECT_EQ(
"which points to an object whose field `field_name` is 1" + OfType("int"), "which points to an object whose field `field_name` is 1" + OfType(internal::GetTypeName<int>()),
Explain(m, &a)); Explain(m, &a));
m = Field("field_name", &AStruct::x, GreaterThan(0)); m = Field("field_name", &AStruct::x, GreaterThan(0));
EXPECT_EQ("which points to an object whose field `field_name` is 1" + EXPECT_EQ("which points to an object whose field `field_name` is 1" +
OfType("int") + ", which is 1 more than 0", OfType(internal::GetTypeName<int>()) + ", which is 1 more than 0",
Explain(m, &a)); Explain(m, &a));
} }
@ -4157,11 +4157,11 @@ TEST(PropertyTest, CanExplainMatchResult) {
AClass a; AClass a;
a.set_n(1); a.set_n(1);
EXPECT_EQ("whose given property is 1" + OfType("int"), Explain(m, a)); EXPECT_EQ("whose given property is 1" + OfType(internal::GetTypeName<int>()), Explain(m, a));
m = Property(&AClass::n, GreaterThan(0)); m = Property(&AClass::n, GreaterThan(0));
EXPECT_EQ( EXPECT_EQ(
"whose given property is 1" + OfType("int") + ", which is 1 more than 0", "whose given property is 1" + OfType(internal::GetTypeName<int>()) + ", which is 1 more than 0",
Explain(m, a)); Explain(m, a));
} }
@ -4170,10 +4170,10 @@ TEST(PropertyTest, CanExplainMatchResultWithPropertyName) {
AClass a; AClass a;
a.set_n(1); a.set_n(1);
EXPECT_EQ("whose property `fancy_name` is 1" + OfType("int"), Explain(m, a)); EXPECT_EQ("whose property `fancy_name` is 1" + OfType(internal::GetTypeName<int>()), Explain(m, a));
m = Property("fancy_name", &AClass::n, GreaterThan(0)); m = Property("fancy_name", &AClass::n, GreaterThan(0));
EXPECT_EQ("whose property `fancy_name` is 1" + OfType("int") + EXPECT_EQ("whose property `fancy_name` is 1" + OfType(internal::GetTypeName<int>()) +
", which is 1 more than 0", ", which is 1 more than 0",
Explain(m, a)); Explain(m, a));
} }
@ -4261,12 +4261,12 @@ TEST(PropertyForPointerTest, CanExplainMatchResult) {
a.set_n(1); a.set_n(1);
EXPECT_EQ("", Explain(m, static_cast<const AClass*>(nullptr))); EXPECT_EQ("", Explain(m, static_cast<const AClass*>(nullptr)));
EXPECT_EQ( EXPECT_EQ(
"which points to an object whose given property is 1" + OfType("int"), "which points to an object whose given property is 1" + OfType(internal::GetTypeName<int>()),
Explain(m, &a)); Explain(m, &a));
m = Property(&AClass::n, GreaterThan(0)); m = Property(&AClass::n, GreaterThan(0));
EXPECT_EQ("which points to an object whose given property is 1" + EXPECT_EQ("which points to an object whose given property is 1" +
OfType("int") + ", which is 1 more than 0", OfType(internal::GetTypeName<int>()) + ", which is 1 more than 0",
Explain(m, &a)); Explain(m, &a));
} }
@ -4277,12 +4277,12 @@ TEST(PropertyForPointerTest, CanExplainMatchResultWithPropertyName) {
a.set_n(1); a.set_n(1);
EXPECT_EQ("", Explain(m, static_cast<const AClass*>(nullptr))); EXPECT_EQ("", Explain(m, static_cast<const AClass*>(nullptr)));
EXPECT_EQ("which points to an object whose property `fancy_name` is 1" + EXPECT_EQ("which points to an object whose property `fancy_name` is 1" +
OfType("int"), OfType(internal::GetTypeName<int>()),
Explain(m, &a)); Explain(m, &a));
m = Property("fancy_name", &AClass::n, GreaterThan(0)); m = Property("fancy_name", &AClass::n, GreaterThan(0));
EXPECT_EQ("which points to an object whose property `fancy_name` is 1" + EXPECT_EQ("which points to an object whose property `fancy_name` is 1" +
OfType("int") + ", which is 1 more than 0", OfType(internal::GetTypeName<int>()) + ", which is 1 more than 0",
Explain(m, &a)); Explain(m, &a));
} }
@ -4316,11 +4316,11 @@ int IntFunction(int input) { return input == 42 ? 80 : 90; }
TEST(ResultOfTest, CanExplainMatchResult) { TEST(ResultOfTest, CanExplainMatchResult) {
Matcher<int> matcher = ResultOf(&IntFunction, Ge(85)); Matcher<int> matcher = ResultOf(&IntFunction, Ge(85));
EXPECT_EQ("which is mapped by the given callable to 90" + OfType("int"), EXPECT_EQ("which is mapped by the given callable to 90" + OfType(internal::GetTypeName<int>()),
Explain(matcher, 36)); Explain(matcher, 36));
matcher = ResultOf(&IntFunction, GreaterThan(85)); matcher = ResultOf(&IntFunction, GreaterThan(85));
EXPECT_EQ("which is mapped by the given callable to 90" + OfType("int") + EXPECT_EQ("which is mapped by the given callable to 90" + OfType(internal::GetTypeName<int>()) +
", which is 5 more than 85", Explain(matcher, 36)); ", which is 5 more than 85", Explain(matcher, 36));
} }