Commit a8ce8d27 authored by xiabo's avatar xiabo
Browse files

修改googletest版本

parent 0a21fff9
...@@ -1182,8 +1182,8 @@ TEST(SizeIsTest, WorksWithMinimalistCustomType) { ...@@ -1182,8 +1182,8 @@ TEST(SizeIsTest, WorksWithMinimalistCustomType) {
TEST(SizeIsTest, CanDescribeSelf) { TEST(SizeIsTest, CanDescribeSelf) {
Matcher<vector<int>> m = SizeIs(2); Matcher<vector<int>> m = SizeIs(2);
EXPECT_EQ("has a size that is equal to 2", Describe(m)); EXPECT_EQ("size is equal to 2", Describe(m));
EXPECT_EQ("has a size that isn't equal to 2", DescribeNegation(m)); EXPECT_EQ("size isn't equal to 2", DescribeNegation(m));
} }
TEST(SizeIsTest, ExplainsResult) { TEST(SizeIsTest, ExplainsResult) {
......
...@@ -1561,7 +1561,7 @@ TEST(AnyOfArrayTest, Matchers) { ...@@ -1561,7 +1561,7 @@ TEST(AnyOfArrayTest, Matchers) {
} }
TEST_P(AnyOfArrayTestP, ExplainsMatchResultCorrectly) { TEST_P(AnyOfArrayTestP, ExplainsMatchResultCorrectly) {
// AnyOfArray and AllOfArray use the same underlying template-template, // AnyOfArray and AllOfArry use the same underlying template-template,
// thus it is sufficient to test one here. // thus it is sufficient to test one here.
const std::vector<int> v0{}; const std::vector<int> v0{};
const std::vector<int> v1{1}; const std::vector<int> v1{1};
...@@ -1615,20 +1615,6 @@ TEST(MatcherPMacroTest, WorksOnMoveOnlyType) { ...@@ -1615,20 +1615,6 @@ TEST(MatcherPMacroTest, WorksOnMoveOnlyType) {
EXPECT_THAT(p, Not(UniquePointee(2))); EXPECT_THAT(p, Not(UniquePointee(2)));
} }
MATCHER(EnsureNoUnusedButMarkedUnusedWarning, "") { return (arg % 2) == 0; }
TEST(MockMethodMockFunctionTest, EnsureNoUnusedButMarkedUnusedWarning) {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic error "-Wused-but-marked-unused"
#endif
// https://github.com/google/googletest/issues/4055
EXPECT_THAT(0, EnsureNoUnusedButMarkedUnusedWarning());
#ifdef __clang__
#pragma clang diagnostic pop
#endif
}
#if GTEST_HAS_EXCEPTIONS #if GTEST_HAS_EXCEPTIONS
// std::function<void()> is used below for compatibility with older copies of // std::function<void()> is used below for compatibility with older copies of
......
...@@ -739,12 +739,11 @@ TEST(ExpectCallTest, CatchesTooFewCalls) { ...@@ -739,12 +739,11 @@ TEST(ExpectCallTest, CatchesTooFewCalls) {
EXPECT_NONFATAL_FAILURE( EXPECT_NONFATAL_FAILURE(
{ // NOLINT { // NOLINT
MockB b; MockB b;
EXPECT_CALL(b, DoB(5)).Description("DoB Method").Times(AtLeast(2)); EXPECT_CALL(b, DoB(5)).Times(AtLeast(2));
b.DoB(5); b.DoB(5);
}, },
"Actual function \"DoB Method\" call count " "Actual function call count doesn't match EXPECT_CALL(b, DoB(5))...\n"
"doesn't match EXPECT_CALL(b, DoB(5))...\n"
" Expected: to be called at least twice\n" " Expected: to be called at least twice\n"
" Actual: called once - unsatisfied and active"); " Actual: called once - unsatisfied and active");
} }
...@@ -1065,7 +1064,7 @@ TEST(UnexpectedCallTest, UnmatchedArguments) { ...@@ -1065,7 +1064,7 @@ TEST(UnexpectedCallTest, UnmatchedArguments) {
// Tests that Google Mock explains that an expectation with // Tests that Google Mock explains that an expectation with
// unsatisfied pre-requisites doesn't match the call. // unsatisfied pre-requisites doesn't match the call.
TEST(UnexpectedCallTest, UnsatisfiedPrerequisites) { TEST(UnexpectedCallTest, UnsatisifiedPrerequisites) {
Sequence s1, s2; Sequence s1, s2;
MockB b; MockB b;
EXPECT_CALL(b, DoB(1)).InSequence(s1); EXPECT_CALL(b, DoB(1)).InSequence(s1);
...@@ -1149,11 +1148,10 @@ TEST(ExcessiveCallTest, DoesDefaultAction) { ...@@ -1149,11 +1148,10 @@ TEST(ExcessiveCallTest, DoesDefaultAction) {
// When there is no ON_CALL(), the default value for the return type // When there is no ON_CALL(), the default value for the return type
// should be returned. // should be returned.
MockB b; MockB b;
EXPECT_CALL(b, DoB(0)).Description("DoB Method").Times(0); EXPECT_CALL(b, DoB(0)).Times(0);
int n = -1; int n = -1;
EXPECT_NONFATAL_FAILURE( EXPECT_NONFATAL_FAILURE(n = b.DoB(0),
n = b.DoB(0), "Mock function called more times than expected");
"Mock function \"DoB Method\" called more times than expected");
EXPECT_EQ(0, n); EXPECT_EQ(0, n);
} }
...@@ -1161,11 +1159,10 @@ TEST(ExcessiveCallTest, DoesDefaultAction) { ...@@ -1161,11 +1159,10 @@ TEST(ExcessiveCallTest, DoesDefaultAction) {
// the failure message contains the argument values. // the failure message contains the argument values.
TEST(ExcessiveCallTest, GeneratesFailureForVoidFunction) { TEST(ExcessiveCallTest, GeneratesFailureForVoidFunction) {
MockA a; MockA a;
EXPECT_CALL(a, DoA(_)).Description("DoA Method").Times(0); EXPECT_CALL(a, DoA(_)).Times(0);
EXPECT_NONFATAL_FAILURE( EXPECT_NONFATAL_FAILURE(
a.DoA(9), a.DoA(9),
"Mock function \"DoA Method\" called more times than expected - " "Mock function called more times than expected - returning directly.\n"
"returning directly.\n"
" Function call: DoA(9)\n" " Function call: DoA(9)\n"
" Expected: to be never called\n" " Expected: to be never called\n"
" Actual: called once - over-saturated and active"); " Actual: called once - over-saturated and active");
...@@ -2062,7 +2059,7 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture { ...@@ -2062,7 +2059,7 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture {
"call should not happen. Do not suppress it by blindly adding " "call should not happen. Do not suppress it by blindly adding "
"an EXPECT_CALL() if you don't mean to enforce the call. " "an EXPECT_CALL() if you don't mean to enforce the call. "
"See " "See "
"https://github.com/google/googletest/blob/main/docs/" "https://github.com/google/googletest/blob/master/docs/"
"gmock_cook_book.md#" "gmock_cook_book.md#"
"knowing-when-to-expect for details."; "knowing-when-to-expect for details.";
......
...@@ -159,9 +159,6 @@ class GMockOutputTest(gmock_test_utils.TestCase): ...@@ -159,9 +159,6 @@ class GMockOutputTest(gmock_test_utils.TestCase):
golden_file = open(GOLDEN_PATH, 'rb') golden_file = open(GOLDEN_PATH, 'rb')
golden = golden_file.read().decode('utf-8') golden = golden_file.read().decode('utf-8')
golden_file.close() golden_file.close()
# On Windows the repository might have been checked out with \r\n line
# endings, so normalize it here.
golden = ToUnixLineEnding(golden)
# The normalized output should match the golden file. # The normalized output should match the golden file.
self.assertEqual(golden, output) self.assertEqual(golden, output)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment