You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Specify which whitespace definition is used for matchers #196
I'd be nice if matchers involving whitespace, like equalToCompressingWhiteSpace would expand on which whitespace definition is used since there're a lot of them out there. For instance, it's not even clear whether Hamcrest considers newline characters whitespace or not. Wikipedia mentions a unicode character property "WSpace=Y" which seems reasonable.
I would like to work with this issue. I have tried to expand equalToCompressingWhiteSpace by adding a property whiteSpaceType which is a enum type variable with 6 types of whitespace: space, tab, line feed, form feed, carriagereturn, mix(mix types above), and I modify the constructor and stripSpaces to strip string according to different types of whitespace. To prevent conflicts, I added 6 types of matcher generators, like public static Matcher<String> equalToCompressingSPACE(String expectedString){}.
Interesting point. Another option would be to introduce a policy object for the kind of white space to be stripped, that would allow new combinations. With the current approach, you could stash the regex in the enum value, which would avoid the chained if statements (which should be a switch anyway).
Interesting point. Another option would be to introduce a policy object for the kind of white space to be stripped, that would allow new combinations. With the current approach, you could stash the regex in the enum value, which would avoid the chained if statements (which should be a switch anyway).
Activity
sf105 commentedon Apr 3, 2018
This is a good point.
Harlan1997 commentedon Apr 25, 2021
I would like to work with this issue. I have tried to expand
equalToCompressingWhiteSpaceby adding a propertywhiteSpaceTypewhich is a enum type variable with 6 types of whitespace: space, tab, line feed, form feed, carriagereturn, mix(mix types above), and I modify the constructor andstripSpacesto strip string according to different types of whitespace. To prevent conflicts, I added 6 types of matcher generators, likepublic static Matcher<String> equalToCompressingSPACE(String expectedString){}.enhancement on isuue hamcrest#196
update test according to issue hamcrest#196
sf105 commentedon Apr 25, 2021
Interesting point. Another option would be to introduce a policy object for the kind of white space to be stripped, that would allow new combinations. With the current approach, you could stash the regex in the enum value, which would avoid the chained
ifstatements (which should be aswitchanyway).enhancement on issue hamcrest#196
Harlan1997 commentedon May 24, 2021
Thank you. I will have a try.