org.hamcrest.text
Class IsEqualIgnoringWhiteSpace
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<String>
org.hamcrest.text.IsEqualIgnoringWhiteSpace
- All Implemented Interfaces:
- Matcher<String>, SelfDescribing
public class IsEqualIgnoringWhiteSpace
- extends TypeSafeMatcher<String>
Tests if a string is equal to another string, ignoring any changes in whitespace.
IsEqualIgnoringWhiteSpace
public IsEqualIgnoringWhiteSpace(String string)
matchesSafely
public boolean matchesSafely(String item)
- Specified by:
matchesSafely in class TypeSafeMatcher<String>
describeMismatchSafely
public void describeMismatchSafely(String item,
Description mismatchDescription)
- Overrides:
describeMismatchSafely in class TypeSafeMatcher<String>
describeTo
public void describeTo(Description description)
stripSpace
public String stripSpace(String toBeStripped)
equalToIgnoringWhiteSpace
public static Matcher<String> equalToIgnoringWhiteSpace(String expectedString)
- Creates a matcher of
String that matches when the examined string is equal to
the specified expectedString, when whitespace differences are (mostly) ignored. To be
exact, the following whitespace rules are applied:
- all leading and trailing whitespace of both the expectedString and the examined string are ignored
- any remaining whitespace, appearing within either string, is collapsed to a single space before comparison
For example:
assertThat(" my\tfoo bar ", equalToIgnoringWhiteSpace(" my foo bar"))
- Parameters:
expectedString - the expected value of matched strings
Copyright © 2014. All rights reserved.