Enables more verbose output for expectations (by Sverre Sundsdal); Fixes information loss warning when compiled by VC8.0 with /Wp64; Skips two tests on Windows Mobile that don't work there.
This commit is contained in:
parent
7db42db1c6
commit
6c54a5e1f9
@ -31,6 +31,7 @@ Paneendra Ba <paneendra@google.com>
|
|||||||
Paul Menage <menage@google.com>
|
Paul Menage <menage@google.com>
|
||||||
Piotr Kaminski <piotrk@google.com>
|
Piotr Kaminski <piotrk@google.com>
|
||||||
Russ Rufer <russ@pentad.com>
|
Russ Rufer <russ@pentad.com>
|
||||||
|
Sverre Sundsdal <sundsdal@gmail.com>
|
||||||
Takeshi Yoshino <tyoshino@google.com>
|
Takeshi Yoshino <tyoshino@google.com>
|
||||||
Vadim Berman <vadimb@google.com>
|
Vadim Berman <vadimb@google.com>
|
||||||
Vlad Losev <vladl@google.com>
|
Vlad Losev <vladl@google.com>
|
||||||
|
@ -561,14 +561,15 @@ extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
|
|||||||
// This class is internal and mustn't be used by user code directly.
|
// This class is internal and mustn't be used by user code directly.
|
||||||
class ExpectationBase {
|
class ExpectationBase {
|
||||||
public:
|
public:
|
||||||
ExpectationBase(const char* file, int line);
|
// source_text is the EXPECT_CALL(...) source that created this Expectation.
|
||||||
|
ExpectationBase(const char* file, int line, const string& source_text);
|
||||||
|
|
||||||
virtual ~ExpectationBase();
|
virtual ~ExpectationBase();
|
||||||
|
|
||||||
// Where in the source file was the expectation spec defined?
|
// Where in the source file was the expectation spec defined?
|
||||||
const char* file() const { return file_; }
|
const char* file() const { return file_; }
|
||||||
int line() const { return line_; }
|
int line() const { return line_; }
|
||||||
|
const char* source_text() const { return source_text_.c_str(); }
|
||||||
// Returns the cardinality specified in the expectation spec.
|
// Returns the cardinality specified in the expectation spec.
|
||||||
const Cardinality& cardinality() const { return cardinality_; }
|
const Cardinality& cardinality() const { return cardinality_; }
|
||||||
|
|
||||||
@ -697,8 +698,9 @@ class ExpectationBase {
|
|||||||
|
|
||||||
// This group of fields are part of the spec and won't change after
|
// This group of fields are part of the spec and won't change after
|
||||||
// an EXPECT_CALL() statement finishes.
|
// an EXPECT_CALL() statement finishes.
|
||||||
const char* file_; // The file that contains the expectation.
|
const char* file_; // The file that contains the expectation.
|
||||||
int line_; // The line number of the expectation.
|
int line_; // The line number of the expectation.
|
||||||
|
const string source_text_; // The EXPECT_CALL(...) source text.
|
||||||
// True iff the cardinality is specified explicitly.
|
// True iff the cardinality is specified explicitly.
|
||||||
bool cardinality_specified_;
|
bool cardinality_specified_;
|
||||||
Cardinality cardinality_; // The cardinality of the expectation.
|
Cardinality cardinality_; // The cardinality of the expectation.
|
||||||
@ -724,11 +726,13 @@ class TypedExpectation : public ExpectationBase {
|
|||||||
typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
|
typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
|
||||||
typedef typename Function<F>::Result Result;
|
typedef typename Function<F>::Result Result;
|
||||||
|
|
||||||
TypedExpectation(FunctionMockerBase<F>* owner, const char* file, int line,
|
TypedExpectation(FunctionMockerBase<F>* owner,
|
||||||
|
const char* file, int line, const string& source_text,
|
||||||
const ArgumentMatcherTuple& m)
|
const ArgumentMatcherTuple& m)
|
||||||
: ExpectationBase(file, line),
|
: ExpectationBase(file, line, source_text),
|
||||||
owner_(owner),
|
owner_(owner),
|
||||||
matchers_(m),
|
matchers_(m),
|
||||||
|
extra_matcher_specified_(false),
|
||||||
// By default, extra_matcher_ should match anything. However,
|
// By default, extra_matcher_ should match anything. However,
|
||||||
// we cannot initialize it with _ as that triggers a compiler
|
// we cannot initialize it with _ as that triggers a compiler
|
||||||
// bug in Symbian's C++ compiler (cannot decide between two
|
// bug in Symbian's C++ compiler (cannot decide between two
|
||||||
@ -760,6 +764,7 @@ class TypedExpectation : public ExpectationBase {
|
|||||||
last_clause_ = kWith;
|
last_clause_ = kWith;
|
||||||
|
|
||||||
extra_matcher_ = m;
|
extra_matcher_ = m;
|
||||||
|
extra_matcher_specified_ = true;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,6 +943,15 @@ class TypedExpectation : public ExpectationBase {
|
|||||||
<< " and "
|
<< " and "
|
||||||
<< (is_retired() ? "retired" : "active");
|
<< (is_retired() ? "retired" : "active");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MaybeDescribeExtraMatcherTo(::std::ostream* os) {
|
||||||
|
if (extra_matcher_specified_) {
|
||||||
|
*os << " Expected args: ";
|
||||||
|
extra_matcher_.DescribeTo(os);
|
||||||
|
*os << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename Function>
|
template <typename Function>
|
||||||
friend class FunctionMockerBase;
|
friend class FunctionMockerBase;
|
||||||
@ -1034,7 +1048,7 @@ class TypedExpectation : public ExpectationBase {
|
|||||||
// we warn the user when the WillOnce() clauses ran out.
|
// we warn the user when the WillOnce() clauses ran out.
|
||||||
::std::stringstream ss;
|
::std::stringstream ss;
|
||||||
DescribeLocationTo(&ss);
|
DescribeLocationTo(&ss);
|
||||||
ss << "Actions ran out.\n"
|
ss << "Actions ran out in " << source_text() << "...\n"
|
||||||
<< "Called " << count << " times, but only "
|
<< "Called " << count << " times, but only "
|
||||||
<< action_count << " WillOnce()"
|
<< action_count << " WillOnce()"
|
||||||
<< (action_count == 1 ? " is" : "s are") << " specified - ";
|
<< (action_count == 1 ? " is" : "s are") << " specified - ";
|
||||||
@ -1078,7 +1092,7 @@ class TypedExpectation : public ExpectationBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Must be done after IncrementCount()!
|
// Must be done after IncrementCount()!
|
||||||
*what << "Expected mock function call.\n";
|
*what << "Mock function call matches " << source_text() <<"...\n";
|
||||||
return GetCurrentAction(mocker, args);
|
return GetCurrentAction(mocker, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1123,7 +1137,7 @@ class TypedExpectation : public ExpectationBase {
|
|||||||
::std::stringstream ss;
|
::std::stringstream ss;
|
||||||
DescribeLocationTo(&ss);
|
DescribeLocationTo(&ss);
|
||||||
ss << "Too " << (too_many ? "many" : "few")
|
ss << "Too " << (too_many ? "many" : "few")
|
||||||
<< " actions specified.\n"
|
<< " actions specified in " << source_text() << "...\n"
|
||||||
<< "Expected to be ";
|
<< "Expected to be ";
|
||||||
cardinality().DescribeTo(&ss);
|
cardinality().DescribeTo(&ss);
|
||||||
ss << ", but has " << (too_many ? "" : "only ")
|
ss << ", but has " << (too_many ? "" : "only ")
|
||||||
@ -1141,6 +1155,7 @@ class TypedExpectation : public ExpectationBase {
|
|||||||
// statement finishes.
|
// statement finishes.
|
||||||
FunctionMockerBase<F>* const owner_;
|
FunctionMockerBase<F>* const owner_;
|
||||||
ArgumentMatcherTuple matchers_;
|
ArgumentMatcherTuple matchers_;
|
||||||
|
bool extra_matcher_specified_;
|
||||||
Matcher<const ArgumentTuple&> extra_matcher_;
|
Matcher<const ArgumentTuple&> extra_matcher_;
|
||||||
std::vector<Action<F> > actions_;
|
std::vector<Action<F> > actions_;
|
||||||
bool repeated_action_specified_; // True if a WillRepeatedly() was specified.
|
bool repeated_action_specified_; // True if a WillRepeatedly() was specified.
|
||||||
@ -1186,9 +1201,10 @@ class MockSpec {
|
|||||||
// the newly created spec.
|
// the newly created spec.
|
||||||
internal::TypedExpectation<F>& InternalExpectedAt(
|
internal::TypedExpectation<F>& InternalExpectedAt(
|
||||||
const char* file, int line, const char* obj, const char* call) {
|
const char* file, int line, const char* obj, const char* call) {
|
||||||
LogWithLocation(internal::INFO, file, line,
|
const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
|
||||||
string("EXPECT_CALL(") + obj + ", " + call + ") invoked");
|
LogWithLocation(internal::INFO, file, line, source_text + " invoked");
|
||||||
return function_mocker_->AddNewExpectation(file, line, matchers_);
|
return function_mocker_->AddNewExpectation(
|
||||||
|
file, line, source_text, matchers_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1440,11 +1456,13 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
|||||||
// Adds and returns an expectation spec for this mock function.
|
// Adds and returns an expectation spec for this mock function.
|
||||||
// L < g_gmock_mutex
|
// L < g_gmock_mutex
|
||||||
TypedExpectation<F>& AddNewExpectation(
|
TypedExpectation<F>& AddNewExpectation(
|
||||||
const char* file, int line,
|
const char* file,
|
||||||
|
int line,
|
||||||
|
const string& source_text,
|
||||||
const ArgumentMatcherTuple& m) {
|
const ArgumentMatcherTuple& m) {
|
||||||
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
|
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
|
||||||
const linked_ptr<TypedExpectation<F> > expectation(
|
const linked_ptr<TypedExpectation<F> > expectation(
|
||||||
new TypedExpectation<F>(this, file, line, m));
|
new TypedExpectation<F>(this, file, line, source_text, m));
|
||||||
expectations_.push_back(expectation);
|
expectations_.push_back(expectation);
|
||||||
|
|
||||||
// Adds this expectation into the implicit sequence if there is one.
|
// Adds this expectation into the implicit sequence if there is one.
|
||||||
@ -1584,9 +1602,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
|||||||
*why << "\n";
|
*why << "\n";
|
||||||
expectations_[i]->DescribeLocationTo(why);
|
expectations_[i]->DescribeLocationTo(why);
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
*why << "tried expectation #" << i;
|
*why << "tried expectation #" << i << ": ";
|
||||||
}
|
}
|
||||||
*why << "\n";
|
*why << expectations_[i]->source_text() << "...\n";
|
||||||
expectations_[i]->DescribeMatchResultTo(args, why);
|
expectations_[i]->DescribeMatchResultTo(args, why);
|
||||||
expectations_[i]->DescribeCallCountTo(why);
|
expectations_[i]->DescribeCallCountTo(why);
|
||||||
}
|
}
|
||||||
@ -1651,10 +1669,12 @@ bool FunctionMockerBase<F>::VerifyAndClearExpectationsLocked() {
|
|||||||
} else if (!exp->IsSatisfied()) {
|
} else if (!exp->IsSatisfied()) {
|
||||||
expectations_met = false;
|
expectations_met = false;
|
||||||
::std::stringstream ss;
|
::std::stringstream ss;
|
||||||
ss << "Actual function call count doesn't match this expectation.\n";
|
ss << "Actual function call count doesn't match "
|
||||||
|
<< exp->source_text() << "...\n";
|
||||||
// No need to show the source file location of the expectation
|
// No need to show the source file location of the expectation
|
||||||
// in the description, as the Expect() call that follows already
|
// in the description, as the Expect() call that follows already
|
||||||
// takes care of it.
|
// takes care of it.
|
||||||
|
exp->MaybeDescribeExtraMatcherTo(&ss);
|
||||||
exp->DescribeCallCountTo(&ss);
|
exp->DescribeCallCountTo(&ss);
|
||||||
Expect(false, exp->file(), exp->line(), ss.str());
|
Expect(false, exp->file(), exp->line(), ss.str());
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <iostream> // NOLINT
|
#include <iostream> // NOLINT
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
@ -55,9 +56,12 @@ namespace internal {
|
|||||||
Mutex g_gmock_mutex(Mutex::NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX);
|
Mutex g_gmock_mutex(Mutex::NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX);
|
||||||
|
|
||||||
// Constructs an ExpectationBase object.
|
// Constructs an ExpectationBase object.
|
||||||
ExpectationBase::ExpectationBase(const char* file, int line)
|
ExpectationBase::ExpectationBase(const char* file,
|
||||||
|
int line,
|
||||||
|
const string& source_text)
|
||||||
: file_(file),
|
: file_(file),
|
||||||
line_(line),
|
line_(line),
|
||||||
|
source_text_(source_text),
|
||||||
cardinality_specified_(false),
|
cardinality_specified_(false),
|
||||||
cardinality_(Exactly(1)),
|
cardinality_(Exactly(1)),
|
||||||
call_count_(0),
|
call_count_(0),
|
||||||
|
@ -173,21 +173,21 @@ TEST(NiceMockTest, NonDefaultConstructor10) {
|
|||||||
nice_bar.That(5, true);
|
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
|
// Tests that NiceMock<Mock> compiles where Mock is a user-defined
|
||||||
// class (as opposed to ::testing::Mock). We had to workaround an
|
// 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
|
// 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
|
// NiceMock to be looked up in the wrong context, and this test
|
||||||
// ensures that our fix works.
|
// ensures that our fix works.
|
||||||
//
|
//
|
||||||
// We have to skip this test on Symbian, as it causes the program to
|
// We have to skip this test on Symbian and Windows Mobile, as it
|
||||||
// crash there, for reasons unclear to us yet.
|
// causes the program to crash there, for reasons unclear to us yet.
|
||||||
TEST(NiceMockTest, AcceptsClassNamedMock) {
|
TEST(NiceMockTest, AcceptsClassNamedMock) {
|
||||||
NiceMock< ::Mock> nice;
|
NiceMock< ::Mock> nice;
|
||||||
EXPECT_CALL(nice, DoThis());
|
EXPECT_CALL(nice, DoThis());
|
||||||
nice.DoThis();
|
nice.DoThis();
|
||||||
}
|
}
|
||||||
#endif // !GTEST_OS_SYMBIAN
|
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||||
|
|
||||||
// Tests that a strict mock allows expected calls.
|
// Tests that a strict mock allows expected calls.
|
||||||
TEST(StrictMockTest, AllowsExpectedCall) {
|
TEST(StrictMockTest, AllowsExpectedCall) {
|
||||||
@ -247,21 +247,21 @@ TEST(StrictMockTest, NonDefaultConstructor10) {
|
|||||||
"Uninteresting mock function call");
|
"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
|
// Tests that StrictMock<Mock> compiles where Mock is a user-defined
|
||||||
// class (as opposed to ::testing::Mock). We had to workaround an
|
// 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
|
// 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
|
// StrictMock to be looked up in the wrong context, and this test
|
||||||
// ensures that our fix works.
|
// ensures that our fix works.
|
||||||
//
|
//
|
||||||
// We have to skip this test on Symbian, as it causes the program to
|
// We have to skip this test on Symbian and Windows Mobile, as it
|
||||||
// crash there, for reasons unclear to us yet.
|
// causes the program to crash there, for reasons unclear to us yet.
|
||||||
TEST(StrictMockTest, AcceptsClassNamedMock) {
|
TEST(StrictMockTest, AcceptsClassNamedMock) {
|
||||||
StrictMock< ::Mock> strict;
|
StrictMock< ::Mock> strict;
|
||||||
EXPECT_CALL(strict, DoThis());
|
EXPECT_CALL(strict, DoThis());
|
||||||
strict.DoThis();
|
strict.DoThis();
|
||||||
}
|
}
|
||||||
#endif // !GTEST_OS_SYMBIAN
|
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||||
|
|
||||||
} // namespace gmock_nice_strict_test
|
} // namespace gmock_nice_strict_test
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
@ -571,29 +571,34 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooManyActions) {
|
|||||||
b.DoB(2);
|
b.DoB(2);
|
||||||
}
|
}
|
||||||
const string& output = GetCapturedTestStdout();
|
const string& output = GetCapturedTestStdout();
|
||||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
EXPECT_PRED_FORMAT2(
|
||||||
"Too many actions specified.\n"
|
IsSubstring,
|
||||||
"Expected to be never called, but has 1 WillOnce().",
|
"Too many actions specified in EXPECT_CALL(b, DoB())...\n"
|
||||||
output); // #1
|
"Expected to be never called, but has 1 WillOnce().",
|
||||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
output); // #1
|
||||||
"Too many actions specified.\n"
|
EXPECT_PRED_FORMAT2(
|
||||||
"Expected to be called at most once, "
|
IsSubstring,
|
||||||
"but has 2 WillOnce()s.",
|
"Too many actions specified in EXPECT_CALL(b, DoB())...\n"
|
||||||
output); // #2
|
"Expected to be called at most once, "
|
||||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
"but has 2 WillOnce()s.",
|
||||||
"Too many actions specified.\n"
|
output); // #2
|
||||||
"Expected to be called once, but has 2 WillOnce()s.",
|
EXPECT_PRED_FORMAT2(
|
||||||
output); // #3
|
IsSubstring,
|
||||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
"Too many actions specified in EXPECT_CALL(b, DoB(1))...\n"
|
||||||
"Too many actions specified.\n"
|
"Expected to be called once, but has 2 WillOnce()s.",
|
||||||
"Expected to be never called, but has 0 WillOnce()s "
|
output); // #3
|
||||||
"and a WillRepeatedly().",
|
EXPECT_PRED_FORMAT2(
|
||||||
output); // #4
|
IsSubstring,
|
||||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
"Too many actions specified in EXPECT_CALL(b, DoB())...\n"
|
||||||
"Too many actions specified.\n"
|
"Expected to be never called, but has 0 WillOnce()s "
|
||||||
"Expected to be called once, but has 1 WillOnce() "
|
"and a WillRepeatedly().",
|
||||||
"and a WillRepeatedly().",
|
output); // #4
|
||||||
output); // #5
|
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
|
// Tests that Google Mock warns on having too few actions in an
|
||||||
@ -608,11 +613,12 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooFewActions) {
|
|||||||
CaptureTestStdout();
|
CaptureTestStdout();
|
||||||
b.DoB();
|
b.DoB();
|
||||||
const string& output = GetCapturedTestStdout();
|
const string& output = GetCapturedTestStdout();
|
||||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
EXPECT_PRED_FORMAT2(
|
||||||
"Too few actions specified.\n"
|
IsSubstring,
|
||||||
"Expected to be called between 2 and 3 times, "
|
"Too few actions specified in EXPECT_CALL(b, DoB())...\n"
|
||||||
"but has only 1 WillOnce().",
|
"Expected to be called between 2 and 3 times, "
|
||||||
output);
|
"but has only 1 WillOnce().",
|
||||||
|
output);
|
||||||
b.DoB();
|
b.DoB();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,7 +694,7 @@ TEST(ExpectCallTest, CatchesTooFewCalls) {
|
|||||||
.Times(AtLeast(2));
|
.Times(AtLeast(2));
|
||||||
|
|
||||||
b.DoB(5);
|
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"
|
" Expected: to be called at least twice\n"
|
||||||
" Actual: called once - unsatisfied and active");
|
" Actual: called once - unsatisfied and active");
|
||||||
}
|
}
|
||||||
@ -895,14 +901,14 @@ TEST(UnexpectedCallTest, GeneratesFailureForVoidFunction) {
|
|||||||
"Google Mock tried the following 2 expectations, but none matched:");
|
"Google Mock tried the following 2 expectations, but none matched:");
|
||||||
EXPECT_NONFATAL_FAILURE(
|
EXPECT_NONFATAL_FAILURE(
|
||||||
a2.DoA(2),
|
a2.DoA(2),
|
||||||
"tried expectation #0\n"
|
"tried expectation #0: EXPECT_CALL(a2, DoA(1))...\n"
|
||||||
" Expected arg #0: is equal to 1\n"
|
" Expected arg #0: is equal to 1\n"
|
||||||
" Actual: 2\n"
|
" Actual: 2\n"
|
||||||
" Expected: to be called once\n"
|
" Expected: to be called once\n"
|
||||||
" Actual: called once - saturated and active");
|
" Actual: called once - saturated and active");
|
||||||
EXPECT_NONFATAL_FAILURE(
|
EXPECT_NONFATAL_FAILURE(
|
||||||
a2.DoA(2),
|
a2.DoA(2),
|
||||||
"tried expectation #1\n"
|
"tried expectation #1: EXPECT_CALL(a2, DoA(3))...\n"
|
||||||
" Expected arg #0: is equal to 3\n"
|
" Expected arg #0: is equal to 3\n"
|
||||||
" Actual: 2\n"
|
" Actual: 2\n"
|
||||||
" Expected: to be called once\n"
|
" Expected: to be called once\n"
|
||||||
@ -2046,7 +2052,7 @@ TEST(VerifyAndClearExpectationsTest, SomeMethodsHaveExpectationsAndFail) {
|
|||||||
MockB b;
|
MockB b;
|
||||||
EXPECT_CALL(b, DoB())
|
EXPECT_CALL(b, DoB())
|
||||||
.WillOnce(Return(1));
|
.WillOnce(Return(1));
|
||||||
bool result;
|
bool result = true;
|
||||||
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
|
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
|
||||||
"Actual: never called");
|
"Actual: never called");
|
||||||
ASSERT_FALSE(result);
|
ASSERT_FALSE(result);
|
||||||
@ -2084,7 +2090,7 @@ TEST(VerifyAndClearExpectationsTest, AMethodHasManyExpectations) {
|
|||||||
EXPECT_CALL(b, DoB(_))
|
EXPECT_CALL(b, DoB(_))
|
||||||
.WillOnce(Return(2));
|
.WillOnce(Return(2));
|
||||||
b.DoB(1);
|
b.DoB(1);
|
||||||
bool result;
|
bool result = true;
|
||||||
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
|
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
|
||||||
"Actual: never called");
|
"Actual: never called");
|
||||||
ASSERT_FALSE(result);
|
ASSERT_FALSE(result);
|
||||||
@ -2216,7 +2222,7 @@ TEST(VerifyAndClearTest, Failure) {
|
|||||||
.WillOnce(Return(2));
|
.WillOnce(Return(2));
|
||||||
|
|
||||||
b.DoB(1);
|
b.DoB(1);
|
||||||
bool result;
|
bool result = true;
|
||||||
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClear(&b),
|
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClear(&b),
|
||||||
"Actual: never called");
|
"Actual: never called");
|
||||||
ASSERT_FALSE(result);
|
ASSERT_FALSE(result);
|
||||||
|
@ -161,6 +161,10 @@ TEST_F(GMockOutputTest, UnsatisfiedPrerequisites) {
|
|||||||
foo_.Bar2(1, 0);
|
foo_.Bar2(1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(GMockOutputTest, UnsatisfiedWith) {
|
||||||
|
EXPECT_CALL(foo_, Bar2(_, _)).With(Ge());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(GMockOutputTest, UnsatisfiedExpectation) {
|
TEST_F(GMockOutputTest, UnsatisfiedExpectation) {
|
||||||
EXPECT_CALL(foo_, Bar(_, _, _));
|
EXPECT_CALL(foo_, Bar(_, _, _));
|
||||||
EXPECT_CALL(foo_, Bar2(0, _))
|
EXPECT_CALL(foo_, Bar2(0, _))
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
FILE:#: EXPECT_CALL(foo_, Bar2(0, _)) invoked
|
FILE:#: EXPECT_CALL(foo_, Bar2(0, _)) invoked
|
||||||
Stack trace:
|
Stack trace:
|
||||||
|
|
||||||
FILE:#: Expected mock function call.
|
FILE:#: Mock function call matches EXPECT_CALL(foo_, Bar2(0, _))...
|
||||||
Function call: Bar2(0, 0)
|
Function call: Bar2(0, 0)
|
||||||
Returns: false
|
Returns: false
|
||||||
Stack trace:
|
Stack trace:
|
||||||
@ -13,17 +13,17 @@ Stack trace:
|
|||||||
FILE:#: EXPECT_CALL(foo_, Bar3(0, _)) invoked
|
FILE:#: EXPECT_CALL(foo_, Bar3(0, _)) invoked
|
||||||
Stack trace:
|
Stack trace:
|
||||||
|
|
||||||
FILE:#: Expected mock function call.
|
FILE:#: Mock function call matches EXPECT_CALL(foo_, Bar3(0, _))...
|
||||||
Function call: Bar3(0, 0)
|
Function call: Bar3(0, 0)
|
||||||
Stack trace:
|
Stack trace:
|
||||||
[ OK ] GMockOutputTest.ExpectedCallToVoidFunction
|
[ OK ] GMockOutputTest.ExpectedCallToVoidFunction
|
||||||
[ RUN ] GMockOutputTest.ExplicitActionsRunOut
|
[ RUN ] GMockOutputTest.ExplicitActionsRunOut
|
||||||
|
|
||||||
GMOCK WARNING:
|
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().
|
Expected to be called twice, but has only 1 WillOnce().
|
||||||
GMOCK WARNING:
|
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.
|
Called 2 times, but only 1 WillOnce() is specified - returning default value.
|
||||||
Stack trace:
|
Stack trace:
|
||||||
[ OK ] GMockOutputTest.ExplicitActionsRunOut
|
[ OK ] GMockOutputTest.ExplicitActionsRunOut
|
||||||
@ -35,7 +35,7 @@ Unexpected mock function call - returning default value.
|
|||||||
Returns: false
|
Returns: false
|
||||||
Google Mock tried the following 1 expectation, but it didn't match:
|
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
|
Expected arg #0: is equal to 0
|
||||||
Actual: 1
|
Actual: 1
|
||||||
Expected: to be called once
|
Expected: to be called once
|
||||||
@ -48,7 +48,7 @@ Unexpected mock function call - returning directly.
|
|||||||
Function call: Bar3(1, 0)
|
Function call: Bar3(1, 0)
|
||||||
Google Mock tried the following 1 expectation, but it didn't match:
|
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
|
Expected arg #0: is equal to 0
|
||||||
Actual: 1
|
Actual: 1
|
||||||
Expected: to be called once
|
Expected: to be called once
|
||||||
@ -92,12 +92,12 @@ Unexpected mock function call - returning default value.
|
|||||||
Returns: false
|
Returns: false
|
||||||
Google Mock tried the following 2 expectations, but none matched:
|
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
|
Expected: the expectation is active
|
||||||
Actual: it is retired
|
Actual: it is retired
|
||||||
Expected: to be called once
|
Expected: to be called once
|
||||||
Actual: called once - saturated and retired
|
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
|
Expected arg #0: is equal to 0
|
||||||
Actual: 1
|
Actual: 1
|
||||||
Expected arg #1: is equal to 0
|
Expected arg #1: is equal to 0
|
||||||
@ -113,12 +113,12 @@ Unexpected mock function call - returning default value.
|
|||||||
Returns: false
|
Returns: false
|
||||||
Google Mock tried the following 2 expectations, but none matched:
|
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
|
Expected arg #0: is equal to 0
|
||||||
Actual: 1
|
Actual: 1
|
||||||
Expected: to be called once
|
Expected: to be called once
|
||||||
Actual: never called - unsatisfied and active
|
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
|
Expected: all pre-requisites are satisfied
|
||||||
Actual: the following immediate pre-requisites are not satisfied:
|
Actual: the following immediate pre-requisites are not satisfied:
|
||||||
FILE:#: pre-requisite #0
|
FILE:#: pre-requisite #0
|
||||||
@ -134,12 +134,12 @@ Unexpected mock function call - returning default value.
|
|||||||
Returns: false
|
Returns: false
|
||||||
Google Mock tried the following 2 expectations, but none matched:
|
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
|
Expected arg #0: is equal to 0
|
||||||
Actual: 1
|
Actual: 1
|
||||||
Expected: to be called once
|
Expected: to be called once
|
||||||
Actual: never called - unsatisfied and active
|
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
|
Expected: all pre-requisites are satisfied
|
||||||
Actual: the following immediate pre-requisites are not satisfied:
|
Actual: the following immediate pre-requisites are not satisfied:
|
||||||
FILE:#: pre-requisite #0
|
FILE:#: pre-requisite #0
|
||||||
@ -148,13 +148,20 @@ FILE:#: pre-requisite #1
|
|||||||
Expected: to be called once
|
Expected: to be called once
|
||||||
Actual: never called - unsatisfied and active
|
Actual: never called - unsatisfied and active
|
||||||
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites
|
[ 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
|
[ RUN ] GMockOutputTest.UnsatisfiedExpectation
|
||||||
FILE:#: Failure
|
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
|
Expected: to be called twice
|
||||||
Actual: called once - unsatisfied and active
|
Actual: called once - unsatisfied and active
|
||||||
FILE:#: Failure
|
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
|
Expected: to be called once
|
||||||
Actual: never called - unsatisfied and active
|
Actual: never called - unsatisfied and active
|
||||||
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation
|
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation
|
||||||
@ -166,7 +173,7 @@ Unexpected mock function call - returning default value.
|
|||||||
Returns: '\0'
|
Returns: '\0'
|
||||||
Google Mock tried the following 1 expectation, but it didn't match:
|
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"
|
Expected arg #0: references the variable @0x# "Hi"
|
||||||
Actual: "Ho" (is located @0x#)
|
Actual: "Ho" (is located @0x#)
|
||||||
Expected arg #2: is greater than or equal to 0
|
Expected arg #2: is greater than or equal to 0
|
||||||
@ -182,7 +189,7 @@ Unexpected mock function call - returning default value.
|
|||||||
Returns: false
|
Returns: false
|
||||||
Google Mock tried the following 1 expectation, but it didn't match:
|
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
|
Expected args: are a pair (x, y) where x >= y
|
||||||
Actual: don't match
|
Actual: don't match
|
||||||
Expected: to be called once
|
Expected: to be called once
|
||||||
@ -196,7 +203,7 @@ Unexpected mock function call - returning default value.
|
|||||||
Returns: false
|
Returns: false
|
||||||
Google Mock tried the following 1 expectation, but it didn't match:
|
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
|
Expected arg #0: is greater than or equal to 2
|
||||||
Actual: 1
|
Actual: 1
|
||||||
Expected args: are a pair (x, y) where x >= y
|
Expected args: are a pair (x, y) where x >= y
|
||||||
@ -213,7 +220,7 @@ FILE:#:
|
|||||||
Returns: false
|
Returns: false
|
||||||
Google Mock tried the following 1 expectation, but it didn't match:
|
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
|
Expected arg #0: is equal to 2
|
||||||
Actual: 1
|
Actual: 1
|
||||||
Expected arg #1: is equal to 2
|
Expected arg #1: is equal to 2
|
||||||
@ -228,7 +235,7 @@ FILE:#:
|
|||||||
Returns: true
|
Returns: true
|
||||||
Google Mock tried the following 1 expectation, but it didn't match:
|
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
|
Expected arg #0: is equal to 2
|
||||||
Actual: 0
|
Actual: 0
|
||||||
Expected arg #1: is equal to 2
|
Expected arg #1: is equal to 2
|
||||||
@ -271,10 +278,10 @@ Stack trace:
|
|||||||
[ RUN ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction
|
[ RUN ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction
|
||||||
|
|
||||||
GMOCK WARNING:
|
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().
|
Expected to be called twice, but has only 1 WillOnce().
|
||||||
GMOCK WARNING:
|
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:
|
Called 2 times, but only 1 WillOnce() is specified - taking default action specified at:
|
||||||
FILE:#:
|
FILE:#:
|
||||||
Stack trace:
|
Stack trace:
|
||||||
@ -288,6 +295,7 @@ Stack trace:
|
|||||||
[ FAILED ] GMockOutputTest.RetiredExpectation
|
[ FAILED ] GMockOutputTest.RetiredExpectation
|
||||||
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisite
|
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisite
|
||||||
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites
|
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites
|
||||||
|
[ FAILED ] GMockOutputTest.UnsatisfiedWith
|
||||||
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation
|
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation
|
||||||
[ FAILED ] GMockOutputTest.MismatchArguments
|
[ FAILED ] GMockOutputTest.MismatchArguments
|
||||||
[ FAILED ] GMockOutputTest.MismatchWith
|
[ FAILED ] GMockOutputTest.MismatchWith
|
||||||
|
Loading…
Reference in New Issue
Block a user