aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gmock-nice-strict_test.cc16
-rw-r--r--test/gmock-spec-builders_test.cc74
-rw-r--r--test/gmock_output_test_.cc4
-rw-r--r--test/gmock_output_test_golden.txt50
4 files changed, 81 insertions, 63 deletions
diff --git a/test/gmock-nice-strict_test.cc b/test/gmock-nice-strict_test.cc
index 0dc71069..faf0145b 100644
--- a/test/gmock-nice-strict_test.cc
+++ b/test/gmock-nice-strict_test.cc
@@ -173,21 +173,21 @@ TEST(NiceMockTest, NonDefaultConstructor10) {
nice_bar.That(5, true);
}
-#if !GTEST_OS_SYMBIAN
+#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
// Tests that NiceMock<Mock> compiles where Mock is a user-defined
// class (as opposed to ::testing::Mock). We had to workaround an
// MSVC 8.0 bug that caused the symbol Mock used in the definition of
// NiceMock to be looked up in the wrong context, and this test
// ensures that our fix works.
//
-// We have to skip this test on Symbian, as it causes the program to
-// crash there, for reasons unclear to us yet.
+// We have to skip this test on Symbian and Windows Mobile, as it
+// causes the program to crash there, for reasons unclear to us yet.
TEST(NiceMockTest, AcceptsClassNamedMock) {
NiceMock< ::Mock> nice;
EXPECT_CALL(nice, DoThis());
nice.DoThis();
}
-#endif // !GTEST_OS_SYMBIAN
+#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
// Tests that a strict mock allows expected calls.
TEST(StrictMockTest, AllowsExpectedCall) {
@@ -247,21 +247,21 @@ TEST(StrictMockTest, NonDefaultConstructor10) {
"Uninteresting mock function call");
}
-#if !GTEST_OS_SYMBIAN
+#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
// Tests that StrictMock<Mock> compiles where Mock is a user-defined
// class (as opposed to ::testing::Mock). We had to workaround an
// MSVC 8.0 bug that caused the symbol Mock used in the definition of
// StrictMock to be looked up in the wrong context, and this test
// ensures that our fix works.
//
-// We have to skip this test on Symbian, as it causes the program to
-// crash there, for reasons unclear to us yet.
+// We have to skip this test on Symbian and Windows Mobile, as it
+// causes the program to crash there, for reasons unclear to us yet.
TEST(StrictMockTest, AcceptsClassNamedMock) {
StrictMock< ::Mock> strict;
EXPECT_CALL(strict, DoThis());
strict.DoThis();
}
-#endif // !GTEST_OS_SYMBIAN
+#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
} // namespace gmock_nice_strict_test
} // namespace testing
diff --git a/test/gmock-spec-builders_test.cc b/test/gmock-spec-builders_test.cc
index 707d8968..5fd97112 100644
--- a/test/gmock-spec-builders_test.cc
+++ b/test/gmock-spec-builders_test.cc
@@ -571,29 +571,34 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooManyActions) {
b.DoB(2);
}
const string& output = GetCapturedTestStdout();
- EXPECT_PRED_FORMAT2(IsSubstring,
- "Too many actions specified.\n"
- "Expected to be never called, but has 1 WillOnce().",
- output); // #1
- EXPECT_PRED_FORMAT2(IsSubstring,
- "Too many actions specified.\n"
- "Expected to be called at most once, "
- "but has 2 WillOnce()s.",
- output); // #2
- EXPECT_PRED_FORMAT2(IsSubstring,
- "Too many actions specified.\n"
- "Expected to be called once, but has 2 WillOnce()s.",
- output); // #3
- EXPECT_PRED_FORMAT2(IsSubstring,
- "Too many actions specified.\n"
- "Expected to be never called, but has 0 WillOnce()s "
- "and a WillRepeatedly().",
- output); // #4
- EXPECT_PRED_FORMAT2(IsSubstring,
- "Too many actions specified.\n"
- "Expected to be called once, but has 1 WillOnce() "
- "and a WillRepeatedly().",
- output); // #5
+ EXPECT_PRED_FORMAT2(
+ IsSubstring,
+ "Too many actions specified in EXPECT_CALL(b, DoB())...\n"
+ "Expected to be never called, but has 1 WillOnce().",
+ output); // #1
+ EXPECT_PRED_FORMAT2(
+ IsSubstring,
+ "Too many actions specified in EXPECT_CALL(b, DoB())...\n"
+ "Expected to be called at most once, "
+ "but has 2 WillOnce()s.",
+ output); // #2
+ EXPECT_PRED_FORMAT2(
+ IsSubstring,
+ "Too many actions specified in EXPECT_CALL(b, DoB(1))...\n"
+ "Expected to be called once, but has 2 WillOnce()s.",
+ output); // #3
+ EXPECT_PRED_FORMAT2(
+ IsSubstring,
+ "Too many actions specified in EXPECT_CALL(b, DoB())...\n"
+ "Expected to be never called, but has 0 WillOnce()s "
+ "and a WillRepeatedly().",
+ output); // #4
+ EXPECT_PRED_FORMAT2(
+ IsSubstring,
+ "Too many actions specified in EXPECT_CALL(b, DoB(2))...\n"
+ "Expected to be called once, but has 1 WillOnce() "
+ "and a WillRepeatedly().",
+ output); // #5
}
// Tests that Google Mock warns on having too few actions in an
@@ -608,11 +613,12 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooFewActions) {
CaptureTestStdout();
b.DoB();
const string& output = GetCapturedTestStdout();
- EXPECT_PRED_FORMAT2(IsSubstring,
- "Too few actions specified.\n"
- "Expected to be called between 2 and 3 times, "
- "but has only 1 WillOnce().",
- output);
+ EXPECT_PRED_FORMAT2(
+ IsSubstring,
+ "Too few actions specified in EXPECT_CALL(b, DoB())...\n"
+ "Expected to be called between 2 and 3 times, "
+ "but has only 1 WillOnce().",
+ output);
b.DoB();
}
@@ -688,7 +694,7 @@ TEST(ExpectCallTest, CatchesTooFewCalls) {
.Times(AtLeast(2));
b.DoB(5);
- }, "Actual function call count doesn't match this expectation.\n"
+ }, "Actual function call count doesn't match EXPECT_CALL(b, DoB(5))...\n"
" Expected: to be called at least twice\n"
" Actual: called once - unsatisfied and active");
}
@@ -895,14 +901,14 @@ TEST(UnexpectedCallTest, GeneratesFailureForVoidFunction) {
"Google Mock tried the following 2 expectations, but none matched:");
EXPECT_NONFATAL_FAILURE(
a2.DoA(2),
- "tried expectation #0\n"
+ "tried expectation #0: EXPECT_CALL(a2, DoA(1))...\n"
" Expected arg #0: is equal to 1\n"
" Actual: 2\n"
" Expected: to be called once\n"
" Actual: called once - saturated and active");
EXPECT_NONFATAL_FAILURE(
a2.DoA(2),
- "tried expectation #1\n"
+ "tried expectation #1: EXPECT_CALL(a2, DoA(3))...\n"
" Expected arg #0: is equal to 3\n"
" Actual: 2\n"
" Expected: to be called once\n"
@@ -2046,7 +2052,7 @@ TEST(VerifyAndClearExpectationsTest, SomeMethodsHaveExpectationsAndFail) {
MockB b;
EXPECT_CALL(b, DoB())
.WillOnce(Return(1));
- bool result;
+ bool result = true;
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
"Actual: never called");
ASSERT_FALSE(result);
@@ -2084,7 +2090,7 @@ TEST(VerifyAndClearExpectationsTest, AMethodHasManyExpectations) {
EXPECT_CALL(b, DoB(_))
.WillOnce(Return(2));
b.DoB(1);
- bool result;
+ bool result = true;
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
"Actual: never called");
ASSERT_FALSE(result);
@@ -2216,7 +2222,7 @@ TEST(VerifyAndClearTest, Failure) {
.WillOnce(Return(2));
b.DoB(1);
- bool result;
+ bool result = true;
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClear(&b),
"Actual: never called");
ASSERT_FALSE(result);
diff --git a/test/gmock_output_test_.cc b/test/gmock_output_test_.cc
index 8244f10b..c33dc6fb 100644
--- a/test/gmock_output_test_.cc
+++ b/test/gmock_output_test_.cc
@@ -161,6 +161,10 @@ TEST_F(GMockOutputTest, UnsatisfiedPrerequisites) {
foo_.Bar2(1, 0);
}
+TEST_F(GMockOutputTest, UnsatisfiedWith) {
+ EXPECT_CALL(foo_, Bar2(_, _)).With(Ge());
+}
+
TEST_F(GMockOutputTest, UnsatisfiedExpectation) {
EXPECT_CALL(foo_, Bar(_, _, _));
EXPECT_CALL(foo_, Bar2(0, _))
diff --git a/test/gmock_output_test_golden.txt b/test/gmock_output_test_golden.txt
index aeec660f..ed8decac 100644
--- a/test/gmock_output_test_golden.txt
+++ b/test/gmock_output_test_golden.txt
@@ -3,7 +3,7 @@
FILE:#: EXPECT_CALL(foo_, Bar2(0, _)) invoked
Stack trace:
-FILE:#: Expected mock function call.
+FILE:#: Mock function call matches EXPECT_CALL(foo_, Bar2(0, _))...
Function call: Bar2(0, 0)
Returns: false
Stack trace:
@@ -13,17 +13,17 @@ Stack trace:
FILE:#: EXPECT_CALL(foo_, Bar3(0, _)) invoked
Stack trace:
-FILE:#: Expected mock function call.
+FILE:#: Mock function call matches EXPECT_CALL(foo_, Bar3(0, _))...
Function call: Bar3(0, 0)
Stack trace:
[ OK ] GMockOutputTest.ExpectedCallToVoidFunction
[ RUN ] GMockOutputTest.ExplicitActionsRunOut
GMOCK WARNING:
-FILE:#: Too few actions specified.
+FILE:#: Too few actions specified in EXPECT_CALL(foo_, Bar2(_, _))...
Expected to be called twice, but has only 1 WillOnce().
GMOCK WARNING:
-FILE:#: Actions ran out.
+FILE:#: Actions ran out in EXPECT_CALL(foo_, Bar2(_, _))...
Called 2 times, but only 1 WillOnce() is specified - returning default value.
Stack trace:
[ OK ] GMockOutputTest.ExplicitActionsRunOut
@@ -35,7 +35,7 @@ Unexpected mock function call - returning default value.
Returns: false
Google Mock tried the following 1 expectation, but it didn't match:
-FILE:#:
+FILE:#: EXPECT_CALL(foo_, Bar2(0, _))...
Expected arg #0: is equal to 0
Actual: 1
Expected: to be called once
@@ -48,7 +48,7 @@ Unexpected mock function call - returning directly.
Function call: Bar3(1, 0)
Google Mock tried the following 1 expectation, but it didn't match:
-FILE:#:
+FILE:#: EXPECT_CALL(foo_, Bar3(0, _))...
Expected arg #0: is equal to 0
Actual: 1
Expected: to be called once
@@ -92,12 +92,12 @@ Unexpected mock function call - returning default value.
Returns: false
Google Mock tried the following 2 expectations, but none matched:
-FILE:#: tried expectation #0
+FILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(_, _))...
Expected: the expectation is active
Actual: it is retired
Expected: to be called once
Actual: called once - saturated and retired
-FILE:#: tried expectation #1
+FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(0, 0))...
Expected arg #0: is equal to 0
Actual: 1
Expected arg #1: is equal to 0
@@ -113,12 +113,12 @@ Unexpected mock function call - returning default value.
Returns: false
Google Mock tried the following 2 expectations, but none matched:
-FILE:#: tried expectation #0
+FILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(0, 0))...
Expected arg #0: is equal to 0
Actual: 1
Expected: to be called once
Actual: never called - unsatisfied and active
-FILE:#: tried expectation #1
+FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(1, _))...
Expected: all pre-requisites are satisfied
Actual: the following immediate pre-requisites are not satisfied:
FILE:#: pre-requisite #0
@@ -134,12 +134,12 @@ Unexpected mock function call - returning default value.
Returns: false
Google Mock tried the following 2 expectations, but none matched:
-FILE:#: tried expectation #0
+FILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(0, 0))...
Expected arg #0: is equal to 0
Actual: 1
Expected: to be called once
Actual: never called - unsatisfied and active
-FILE:#: tried expectation #1
+FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(1, _))...
Expected: all pre-requisites are satisfied
Actual: the following immediate pre-requisites are not satisfied:
FILE:#: pre-requisite #0
@@ -148,13 +148,20 @@ FILE:#: pre-requisite #1
Expected: to be called once
Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites
+[ RUN ] GMockOutputTest.UnsatisfiedWith
+FILE:#: Failure
+Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(_, _))...
+ Expected args: are a pair (x, y) where x >= y
+ Expected: to be called once
+ Actual: never called - unsatisfied and active
+[ FAILED ] GMockOutputTest.UnsatisfiedWith
[ RUN ] GMockOutputTest.UnsatisfiedExpectation
FILE:#: Failure
-Actual function call count doesn't match this expectation.
+Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(0, _))...
Expected: to be called twice
Actual: called once - unsatisfied and active
FILE:#: Failure
-Actual function call count doesn't match this expectation.
+Actual function call count doesn't match EXPECT_CALL(foo_, Bar(_, _, _))...
Expected: to be called once
Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation
@@ -166,7 +173,7 @@ Unexpected mock function call - returning default value.
Returns: '\0'
Google Mock tried the following 1 expectation, but it didn't match:
-FILE:#:
+FILE:#: EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0)))...
Expected arg #0: references the variable @0x# "Hi"
Actual: "Ho" (is located @0x#)
Expected arg #2: is greater than or equal to 0
@@ -182,7 +189,7 @@ Unexpected mock function call - returning default value.
Returns: false
Google Mock tried the following 1 expectation, but it didn't match:
-FILE:#:
+FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
Expected args: are a pair (x, y) where x >= y
Actual: don't match
Expected: to be called once
@@ -196,7 +203,7 @@ Unexpected mock function call - returning default value.
Returns: false
Google Mock tried the following 1 expectation, but it didn't match:
-FILE:#:
+FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
Expected arg #0: is greater than or equal to 2
Actual: 1
Expected args: are a pair (x, y) where x >= y
@@ -213,7 +220,7 @@ FILE:#:
Returns: false
Google Mock tried the following 1 expectation, but it didn't match:
-FILE:#:
+FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
Expected arg #0: is equal to 2
Actual: 1
Expected arg #1: is equal to 2
@@ -228,7 +235,7 @@ FILE:#:
Returns: true
Google Mock tried the following 1 expectation, but it didn't match:
-FILE:#:
+FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
Expected arg #0: is equal to 2
Actual: 0
Expected arg #1: is equal to 2
@@ -271,10 +278,10 @@ Stack trace:
[ RUN ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction
GMOCK WARNING:
-FILE:#: Too few actions specified.
+FILE:#: Too few actions specified in EXPECT_CALL(foo_, Bar2(_, _))...
Expected to be called twice, but has only 1 WillOnce().
GMOCK WARNING:
-FILE:#: Actions ran out.
+FILE:#: Actions ran out in EXPECT_CALL(foo_, Bar2(_, _))...
Called 2 times, but only 1 WillOnce() is specified - taking default action specified at:
FILE:#:
Stack trace:
@@ -288,6 +295,7 @@ Stack trace:
[ FAILED ] GMockOutputTest.RetiredExpectation
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisite
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites
+[ FAILED ] GMockOutputTest.UnsatisfiedWith
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation
[ FAILED ] GMockOutputTest.MismatchArguments
[ FAILED ] GMockOutputTest.MismatchWith