Closed GoogleCodeExporter closed 9 years ago
Oddly enough I just added HasToString to the PHP library yesterday. Instead of
taking an object of the same type as the value to be asserted, I recommend
accepting a Matcher and having two factory methods: one taking a Matcher and
another taking a String.
The test is then free to pass in a literal string, a Matcher, or any object to
have its toString() method called.* This would make it more generic while still
satisfying the original request.
HasToString(Matcher matcher)
matches(Object actual) { return matcher.matches(actual.toString()); }
hasToString(Matcher matcher) { return new HasToString(matcher); }
hasToString(String expected) { return hasToString(eqaulTo(expected)); }
* IIRC Java automatically calls toString() whenever an object is passed to a
method taking String. If not, add a third factory taking Object.
Original comment by dharkn...@gmail.com
on 27 Jul 2010 at 6:41
Original comment by smgfree...@gmail.com
on 28 Apr 2012 at 11:40
Original issue reported on code.google.com by
illarion.kovalchuk
on 26 Jul 2010 at 1:05Attachments: