Avoids unnecessary printing of call into to internal buffers;
Made the universal value printer safer when printing char[]; Removed duplicated code in InvokeWith; Improved gmock_doctor.py.
This commit is contained in:
@@ -1612,6 +1612,53 @@ TEST_F(GMockVerboseFlagTest, InvalidFlagIsTreatedAsWarning) {
|
||||
|
||||
#endif // 0
|
||||
|
||||
// A helper class that generates a failure when printed. We use it to
|
||||
// ensure that Google Mock doesn't print a value (even to an internal
|
||||
// buffer) when it is not supposed to do so.
|
||||
class PrintMeNot {};
|
||||
|
||||
void PrintTo(PrintMeNot /* dummy */, ::std::ostream* /* os */) {
|
||||
ADD_FAILURE() << "Google Mock is printing a value that shouldn't be "
|
||||
<< "printed even to an internal buffer.";
|
||||
}
|
||||
|
||||
class LogTestHelper {
|
||||
public:
|
||||
MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot));
|
||||
};
|
||||
|
||||
class GMockLogTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() { original_verbose_ = GMOCK_FLAG(verbose); }
|
||||
virtual void TearDown() { GMOCK_FLAG(verbose) = original_verbose_; }
|
||||
|
||||
LogTestHelper helper_;
|
||||
string original_verbose_;
|
||||
};
|
||||
|
||||
TEST_F(GMockLogTest, DoesNotPrintGoodCallInternallyIfVerbosityIsWarning) {
|
||||
GMOCK_FLAG(verbose) = kWarningVerbosity;
|
||||
EXPECT_CALL(helper_, Foo(_))
|
||||
.WillOnce(Return(PrintMeNot()));
|
||||
helper_.Foo(PrintMeNot()); // This is an expected call.
|
||||
}
|
||||
|
||||
TEST_F(GMockLogTest, DoesNotPrintGoodCallInternallyIfVerbosityIsError) {
|
||||
GMOCK_FLAG(verbose) = kErrorVerbosity;
|
||||
EXPECT_CALL(helper_, Foo(_))
|
||||
.WillOnce(Return(PrintMeNot()));
|
||||
helper_.Foo(PrintMeNot()); // This is an expected call.
|
||||
}
|
||||
|
||||
TEST_F(GMockLogTest, DoesNotPrintWarningInternallyIfVerbosityIsError) {
|
||||
GMOCK_FLAG(verbose) = kErrorVerbosity;
|
||||
ON_CALL(helper_, Foo(_))
|
||||
.WillByDefault(Return(PrintMeNot()));
|
||||
helper_.Foo(PrintMeNot()); // This should generate a warning.
|
||||
}
|
||||
|
||||
// Tests Mock::AllowLeak().
|
||||
|
||||
TEST(AllowLeakTest, AllowsLeakingUnusedMockObject) {
|
||||
MockA* a = new MockA;
|
||||
Mock::AllowLeak(a);
|
||||
|
||||
Reference in New Issue
Block a user