MrazqRuby / googlemock

Automatically exported from code.google.com/p/googlemock
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Expectation failure produces non MSVC-compatible message #135

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
This is fixed in revision 356.

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