Skip to content
This repository was archived by the owner on Jul 17, 2019. It is now read-only.
This repository was archived by the owner on Jul 17, 2019. It is now read-only.

Better error reporting for undefined default return values #12

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. Lets say we add the following test in test/gmock-spec-builders_test.cc:
TEST(UninterestingCallTest, FailureOnUndefinedDefaultAction) {
  MockA a;
  Result r = a.ReturnResult(0);
}

2. Or a test like this:
TEST(UnexpectedCallTest, FailyureOnUnderfinedDefaultAction) {
  FLAGS_gmock_verbose = "info";
  MockA a;
  EXPECT_CALL(a, ReturnResult(1)).WillOnce(Return(Result()));
  Result r = a.ReturnResult(0);
}


What is the expected output? What do you see instead?
To my understanding the first one is an Uninteresting call while the second
is an Unexpected call. Both have the same output:

Stack trace:
./include/gmock/gmock-actions.h:73: Failure
Default action undefined for the function return type.
Abort trap

What version of the product are you using? On what operating system?
1.0
Mac OS X

Please provide any additional information below.
I would like to see test output like this:

Uninteresting mock function call - returning default value.
    Function call: ReturnResult(0)
    Undefined default return value.
Abort trap

And like this:

Unexpected mock function call - returning default value.
    Function call: ReturnResult(0)
    Undefined default return value.
Abort trap

This is caused because we are trying do a
BuiltInDefaultValue<Result>::Get() which dies since Result has no default
value. I suggest we add a way to check whether we have a defined default
value before we call FunctionMockerBase::PerformDefaultAction(...)

I have a patch which does this.

Original issue reported on code.google.com by sunds...@gmail.com on 18 Dec 2008 at 9:07

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions