Float output has insufficient precision to describe matcher failures
Opened this issue · 3 comments
GoogleCodeExporter commented
> What steps will reproduce the problem?
Fail a DoubleEq matcher check with a large value.
> What is the expected output? What do you see instead?
The current output isn't especially helpful:
foo_test.cc:110: tried expectation #0: EXPECT_CALL(mock_obj, foo(
DoubleEq(start), DoubleEq(end)))...
Expected arg #0: is approximately 1260570880.4555497
Actual: 1.26057e+09
Expected arg #1: is approximately 1260570890.4555497
Actual: 1.26057e+09
There isn't enough precision in the Actual display to see why the match
failed.
The attached patch makes the Actual: line use the same output format as the
Expected line. This makes the output clearly show the reason for the
matcher failure (in this case, rounding):
foo_test.cc:110: tried expectation #0: EXPECT_CALL(mock_obj, foo(
DoubleEq(start), DoubleEq(end)))...
Expected arg #0: is approximately 1260572265.1954534
Actual: 1260572265
Expected arg #1: is approximately 1260572275.1954534
Actual: 1260572275
However, this patch also causes changes in
test/gmock_output_test_golden.txt:
@@ -172 +172 @@
- Function call: Bar(@0x# "Ho", 0, -0.1)
+ Function call: Bar(@0x# "Ho", 0, -0.10000000000000001)
@@ -180 +180 @@
- Actual: -0.1
+ Actual: -0.10000000000000001
This does not seem ideal. What is the best option here?
> What version of the product are you using? On what operating system?
SVN on GNU
Original issue reported on code.google.com by swor...@google.com
on 14 Dec 2009 at 6:25
Attachments:
GoogleCodeExporter commented
Original comment by w...@google.com
on 17 Dec 2009 at 5:43
- Changed state: Accepted
- Added labels: OpSys-All, Type-Enhancement, Usability
- Removed labels: Type-Defect
GoogleCodeExporter commented
We should fix gtest's issue 246
(http://code.google.com/p/googletest/issues/detail?id=246), then this will be
fixed too.
Original comment by w...@google.com
on 5 Jan 2010 at 4:33
GoogleCodeExporter commented
There is probably more to it than fixing gtest issue 246, as gmock may not be
using
Message to print values here. I have to read the code and add tests to be sure.
Original comment by w...@google.com
on 6 Jan 2010 at 5:16