IsEqualIgnoringWhiteSpace matcher doesn't behave as expected

69 views
Skip to first unread message

Richard Wise

unread,
Feb 3, 2015, 12:07:51 AM2/3/15
to hamcre...@googlegroups.com
Hello,

I'm looking to use Hamcrest matchers for whitespace-insensitive comparisons of generated JSON. When I saw IsEqualIgnoringWhiteSpace I assumed that it would compare Strings ignoring whitespace. However, it appears as though the logic is a bit more complicated than that - it seems to replace multiple whitespace characters with a single space which means that the following are not equal:

"Foo" : "Bar"


and

"Foo":"Bar"


I would suggest that this matcher is renamed to IsEqualNormalisingWhiteSpace or something similar, with a new matcher created called IsEqualIgnoringWhiteSpace that actually removes all whitespace before comparison.
Reply all
Reply to author
Forward
0 new messages