org.hamcrest.text
Class IsEqualIgnoringWhiteSpace
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<java.lang.String>
org.hamcrest.text.IsEqualIgnoringWhiteSpace
- All Implemented Interfaces:
- org.hamcrest.Matcher<java.lang.String>, org.hamcrest.SelfDescribing
public class IsEqualIgnoringWhiteSpace
- extends org.hamcrest.TypeSafeMatcher<java.lang.String>
Tests if a string is equal to another string, ignoring any changes in whitespace.
Method Summary |
void |
describeMismatchSafely(java.lang.String item,
org.hamcrest.Description mismatchDescription)
|
void |
describeTo(org.hamcrest.Description description)
|
static org.hamcrest.Matcher<java.lang.String> |
equalToIgnoringWhiteSpace(java.lang.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. |
boolean |
matchesSafely(java.lang.String item)
|
java.lang.String |
stripSpace(java.lang.String toBeStripped)
|
Methods inherited from class org.hamcrest.TypeSafeMatcher |
describeMismatch, matches |
Methods inherited from class org.hamcrest.BaseMatcher |
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
IsEqualIgnoringWhiteSpace
public IsEqualIgnoringWhiteSpace(java.lang.String string)
matchesSafely
public boolean matchesSafely(java.lang.String item)
- Specified by:
matchesSafely
in class org.hamcrest.TypeSafeMatcher<java.lang.String>
describeMismatchSafely
public void describeMismatchSafely(java.lang.String item,
org.hamcrest.Description mismatchDescription)
- Overrides:
describeMismatchSafely
in class org.hamcrest.TypeSafeMatcher<java.lang.String>
describeTo
public void describeTo(org.hamcrest.Description description)
stripSpace
public java.lang.String stripSpace(java.lang.String toBeStripped)
equalToIgnoringWhiteSpace
public static org.hamcrest.Matcher<java.lang.String> equalToIgnoringWhiteSpace(java.lang.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