Lines Matching defs:Explain
160 std::string Explain(const MatcherType& m, const Value& x) {
247 EXPECT_EQ("value % 2 == 0", Explain(m, 2));
248 EXPECT_EQ("value % 2 == 1", Explain(m, 3));
555 EXPECT_EQ("% 2 == 0", Explain(m1, 42));
566 EXPECT_EQ("% 2 == 0", Explain(m2, '\x42'));
1282 EXPECT_THAT(Explain(Matcher<const int&>(Ref(n)), n),
1286 EXPECT_THAT(Explain(Matcher<const int&>(Ref(n)), m),
1495 Explain(m, make_pair(5, true)));
1497 Explain(m, make_pair(15, true)));
1599 // If neither field matches, Pair() should explain about the first
1603 Explain(m, make_pair(-1, -2)));
1606 // explain about the second field.
1608 Explain(m, make_pair(1, -2)));
1611 // should explain about the first field.
1613 Explain(m, make_pair(-1, 2)));
1615 // If both fields match, Pair() should explain about them both.
1619 Explain(m, make_pair(1, 2)));
1626 Explain(explain_first, make_pair(1, 0)));
1633 Explain(explain_second, make_pair(0, 1)));
2627 // Successful match. Both matchers need to explain. The second
2631 EXPECT_EQ("which is 15 more than 10", Explain(m, 25));
2633 // Successful match. Both matchers need to explain.
2636 Explain(m, 30));
2638 // Successful match. All matchers need to explain. The second
2642 Explain(m, 25));
2644 // Successful match. All matchers need to explain.
2648 Explain(m, 40));
2651 // explain.
2653 EXPECT_EQ("which is 5 less than 10", Explain(m, 5));
2656 // explain. Since it doesn't given an explanation, nothing is
2659 EXPECT_EQ("", Explain(m, 40));
2662 // explain.
2664 EXPECT_EQ("which is 5 less than 20", Explain(m, 15));
2843 // Failed match. Both matchers need to explain. The second
2847 EXPECT_EQ("which is 5 less than 10", Explain(m, 5));
2849 // Failed match. Both matchers need to explain.
2852 Explain(m, 5));
2854 // Failed match. All matchers need to explain. The second
2858 Explain(m, 5));
2860 // Failed match. All matchers need to explain.
2864 Explain(m, 5));
2867 // explain.
2869 EXPECT_EQ("which is 5 more than 10", Explain(m, 15));
2872 // explain. Since it doesn't given an explanation, nothing is
2875 EXPECT_EQ("", Explain(m, 0));
2878 // explain.
2880 EXPECT_EQ("which is 5 more than 20", Explain(m, 25));
3592 EXPECT_EQ("", Explain(DoubleNear(2.0, 0.1), 2.05));
3593 EXPECT_EQ("which is 0.2 from 2", Explain(DoubleNear(2.0, 0.1), 2.2));
3594 EXPECT_EQ("which is -0.3 from 2", Explain(DoubleNear(2.0, 0.1), 1.7));
3597 Explain(DoubleNear(2.1, 1e-10), 2.1 + 1.2e-10);
3748 TEST(WhenDynamicCastToTest, Explain) {
3751 EXPECT_THAT(Explain(matcher, null), HasSubstr("NULL"));
3754 EXPECT_THAT(Explain(matcher, &derived), HasSubstr("which points to "));
3758 EXPECT_THAT(Explain(ref_matcher, derived),
3835 EXPECT_EQ("", Explain(m, static_cast<const std::string*>(nullptr)));
3840 Explain(m2, &n));
3846 EXPECT_EQ("which points to 42" + OfType("int"), Explain(m, &n));
3999 // Tests that Field() can explain the match result.
4005 EXPECT_EQ("whose given field is 1" + OfType("int"), Explain(m, a));
4010 Explain(m, a));
4018 EXPECT_EQ("whose field `field_name` is 1" + OfType("int"), Explain(m, a));
4023 Explain(m, a));
4091 // Tests that Field() can explain the result of matching a pointer.
4097 EXPECT_EQ("", Explain(m, static_cast<const AStruct*>(nullptr)));
4099 Explain(m, &a));
4103 ", which is 1 more than 0", Explain(m, &a));
4111 EXPECT_EQ("", Explain(m, static_cast<const AStruct*>(nullptr)));
4114 Explain(m, &a));
4119 Explain(m, &a));
4285 // Tests that Property() can explain the match result.
4291 EXPECT_EQ("whose given property is 1" + OfType("int"), Explain(m, a));
4296 Explain(m, a));
4304 EXPECT_EQ("whose property `fancy_name` is 1" + OfType("int"), Explain(m, a));
4309 Explain(m, a));
4387 // Tests that Property() can explain the result of matching a pointer.
4393 EXPECT_EQ("", Explain(m, static_cast<const AClass*>(nullptr)));
4396 Explain(m, &a));
4401 Explain(m, &a));
4409 EXPECT_EQ("", Explain(m, static_cast<const AClass*>(nullptr)));
4412 Explain(m, &a));
4417 Explain(m, &a));
4445 // Tests that ResultOf() can explain the match result.
4451 Explain(matcher, 36));
4455 ", which is 5 more than 85", Explain(matcher, 36));
4636 // asked to explain why.
4639 EXPECT_EQ("which is 1 modulo 4", Explain(m, 5));
4643 // asked to explain why.
4646 EXPECT_EQ("which is 2 modulo 4", Explain(m, 6));
4650 // asked to explain why.
4653 EXPECT_EQ("which is 2 modulo 3", Explain(m, 5));
4656 // Tests that when AllOf() succeeds, all matchers are asked to explain
4660 EXPECT_EQ("which is 0 modulo 2, and which is 0 modulo 3", Explain(m, 6));
4665 EXPECT_EQ("", Explain(m, 2));
4670 EXPECT_EQ("which is 1 more than 5", Explain(m, 6));
4741 EXPECT_EQ("", Explain(m, container));
4743 EXPECT_EQ("whose size is 1", Explain(m, container));
4849 EXPECT_EQ("whose size 0 doesn't match", Explain(m1, container));
4850 EXPECT_EQ("whose size 0 matches", Explain(m2, container));
4851 EXPECT_EQ("whose size 0 matches", Explain(m3, container));
4853 Explain(m4, container));
4856 EXPECT_EQ("whose size 2 matches", Explain(m1, container));
4857 EXPECT_EQ("whose size 2 doesn't match", Explain(m2, container));
4858 EXPECT_EQ("whose size 2 doesn't match", Explain(m3, container));
4860 Explain(m4, container));
4885 EXPECT_EQ("", Explain(m, my_set));
4897 Explain(m, test_set));
4908 EXPECT_EQ("which has these unexpected elements: 46", Explain(m, test_set));
4921 Explain(m, test_set));
4933 EXPECT_EQ("", Explain(m, test_set));
4947 Explain(m, test_set));
4960 Explain(m, test_set));
4973 Explain(m, test_set));
4987 EXPECT_EQ("", Explain(m, test_set));
5007 Explain(m, test_map));
5117 Explain(WhenSortedBy(less<int>(), ElementsAre(2, 3)), a));
5119 Explain(WhenSortedBy(less<int>(), ElementsAre(1, 2)), a));
5323 Explain(m1, container));
5325 Explain(m2, container));
5327 Explain(m3, container));
5331 Explain(m4, container));
5335 Explain(m1, container));
5337 Explain(m2, container));
5339 Explain(m3, container));
5343 Explain(m4, container));
6292 EXPECT_EQ("", Explain(m, a));
6297 EXPECT_EQ("", Explain(n, b));
6300 EXPECT_EQ("whose element #0 doesn't match", Explain(n, b));
6306 EXPECT_EQ("", Explain(m, a));
6310 Explain(m, a));
6478 Explain(Pointwise(Gt(), rhs), lhs));
6490 Explain(Pointwise(IsHalfOf(), rhs), lhs));
6497 EXPECT_EQ("", Explain(Pointwise(IsHalfOf(), rhs), lhs));
6505 EXPECT_EQ("", Explain(Pointwise(m1, rhs), lhs));
6511 EXPECT_EQ("", Explain(Pointwise(m2, rhs), lhs));
6598 Explain(UnorderedPointwise(Gt(), rhs), lhs));
6610 Explain(UnorderedPointwise(IsHalfOf(), rhs), lhs));
6668 EXPECT_EQ("whose value 1 matches", Explain(m, SampleOptional<int>(1)));
6669 EXPECT_EQ("whose value 2 doesn't match", Explain(m, SampleOptional<int>(2)));
6725 EXPECT_THAT(Explain(m, SampleVariantIntString(1)),
6727 EXPECT_THAT(Explain(m, SampleVariantIntString("A")),
6729 EXPECT_THAT(Explain(m, SampleVariantIntString(2)),
6817 EXPECT_THAT(Explain(m, SampleAnyType(1)), ContainsRegex("whose value 1"));
6818 EXPECT_THAT(Explain(m, SampleAnyType("A")),
6820 EXPECT_THAT(Explain(m, SampleAnyType(2)), "whose value 2 doesn't match");
6938 Explain(m, std::make_tuple(false, 42, 42)));
6940 Explain(m, std::make_tuple(false, 42, 43)));
6968 Explain(m, std::make_tuple('a', 42, 42)));
6970 Explain(m, std::make_tuple('\0', 42, 43)));