liangzai-cool / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

OrderingComparison#describeMismatchSafely Iinverts actual and expected value relationship #99

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The order in which expected and actual values are appended within 
OrderingComparison#describeMismatchSafely is not consistent with the comparison 
operation, 
resulting in the description of an inverted relationship between the two values.

For example, in the following code #requireThat uses #describeMismatch if the 
matcher fails:

requireThat(new String[] { "" }, is(arrayWithSize(greaterThanOrEqualTo(3))));
=> "Array size <3> was less than <1>"

This is rectified by changing OrderingComparison#describeMismatch to append the 
actual and 
expected values in a manner consistent with how they are compared. Locally I 
decided to leave 
the comparison operation unchanged and to instead exchange the order in which 
the actual and 
expected values are appended.

requireThat(new String[] { "" }, is(arrayWithSize(greaterThanOrEqualTo(3))));
=> Array size <1> was less than <3>

Original issue reported on code.google.com by dewal...@gmail.com on 6 Oct 2009 at 4:14

GoogleCodeExporter commented 9 years ago
Er, that should be *inverts :-)

Original comment by dewal...@gmail.com on 6 Oct 2009 at 4:18

GoogleCodeExporter commented 9 years ago
Which version of hamcrest are you using? I can't find the failure in the code.
Also, can you post your requireThat() implementation?

Original comment by smgfree...@gmail.com on 15 Oct 2009 at 12:50

GoogleCodeExporter commented 9 years ago
I was using 1.2, but it looks like the issue has been resolved in 1.3RC0. 
Thanks!

Original comment by dewal...@gmail.com on 18 Oct 2009 at 3:42

GoogleCodeExporter commented 9 years ago

Original comment by smgfree...@gmail.com on 28 Apr 2012 at 11:43