vegetablemao / googlemock

Automatically exported from code.google.com/p/googlemock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expectation failure produces non MSVC-compatible message

GoogleCodeExporter opened this issue · comments

When expectation fails it produces the following error message:
<cut>
Google Mock tried the following 1 expectation, but it didn't match:

c:\file.cpp:15: EXPECT_CALL(object, Method(0))...
</cut>

Such format is not compatible with MSVC's parser - it cannot find line number 
and scrolls the file to the very top.

This string is built in the ExpectationBase::DescribeLocationTo method
(r352, gmock-spec-builders.h @ 577). I suggest to reuse existing function and 
change the method from
<code>
  void DescribeLocationTo(::std::ostream* os) const {
    *os << file() << ":" << line() << ": ";
  }
</code>

to
<code>
  void DescribeLocationTo(::std::ostream* os) const {
    *os << FormatFileLocation(file(), line());
}
</code>

If it leads to some compilation errors, unnecessary dependencies and so on, 
this version will also suffice:
<code>
  void DescribeLocationTo(::std::ostream* os) const {
#ifdef _MSC_VER
    *os << file() << "(" << line() << "): ";
#else
    *os << file() << ":" << line() << ": ";
#endif
  }
</code>


Original issue reported on code.google.com by yury.mikhaylov on 14 Jan 2011 at 12:54

Original comment by vladlosev on 4 Feb 2011 at 7:43

  • Changed state: Accepted
  • Added labels: Component-UI, OpSys-Windows, Usability
This is fixed in revision 356.

Original comment by vladlosev on 11 Feb 2011 at 11:51

  • Changed state: Fixed