mr-sun / hamcrest

Hamcrest matchers for c++ (using with carnamock)
0 stars 0 forks source link

IsArray.describeMismatchSafely() should use Matcher.describeMismatch #187

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
IsArray.describeMismatchSafely() currently appends the offending object's 
.toString(), which can make to figure out which comparison failed. For example 
hasPropery() has different error messages depending if the method exists or 
returns the wrong value.

It would be nice to change it so the failing matcher could describe the 
mismatch. Something like this:

diff --git a/IsArray.java b/IsArray.java
index fa5a765..24bdea2 100644
--- a/IsArray.java
+++ b/IsArray.java
@@ -6,7 +6,8 @@
       }
       for (int i = 0; i < actual.length; i++) {
         if (!elementMatchers[i].matches(actual[i])) {
-          mismatchDescription.appendText("element " + i + " was 
").appendValue(actual[i]);
+          mismatchDescription.appendText("in element " + i + " ");
+          elementMatchers[i].describeMismatch(actual[i], mismatchDescription);
           return;
         }
       }

Original issue reported on code.google.com by halfu...@gmail.com on 29 Jun 2012 at 2:57

GoogleCodeExporter commented 8 years ago

Original comment by t.denley on 9 Jul 2012 at 6:27

GoogleCodeExporter commented 8 years ago

Original comment by t.denley on 18 Jul 2012 at 4:01

GoogleCodeExporter commented 8 years ago
should be addressed by commit: 
https://github.com/hamcrest/JavaHamcrest/commit/6f59fa88b4923064b2a5a41afd9ad508
ec0cc602

Original comment by t.denley on 18 Jul 2012 at 4:06