OCHamcrest
Defines
Text Matchers
Matcher Library

Matchers that perform text comparisons.
More...

Defines

#define equalToIgnoringCase   HC_equalToIgnoringCase
 equalToIgnoringCase(aString) - Matches if object is a string equal to a given string, ignoring case differences.
#define equalToIgnoringWhiteSpace   HC_equalToIgnoringWhiteSpace
 equalToIgnoringWhiteSpace(aString) - Matches if object is a string equal to a given string, ignoring differences in whitespace.
#define containsString   HC_containsString
 containsString(aString) - Matches if object is a string containing a given string.
#define stringContainsInOrder   HC_stringContainsInOrder
 stringContainsInOrder(firstString, ...) - Matches if object is a string containing a given list of substrings in relative order.
#define endsWith   HC_endsWith
 endsWith(aString) - Matches if object is a string ending with a given string.
#define startsWith   HC_startsWith
 startsWith(aString) - Matches if object is a string starting with a given string.

Detailed Description

Matchers that perform text comparisons.

Define Documentation

containsString(aString) - Matches if object is a string containing a given string.

Parameters:
aStringThe string to search for. This value must not be nil.

This matcher first checks whether the evaluated object is a string. If so, it checks whether it contains aString.

Example:

containsString("def")

will match "abcdefg".

(In the event of a name clash, don't #define HC_SHORTHAND and use the synonym HC_containsString instead.)

#define endsWith   HC_endsWith

endsWith(aString) - Matches if object is a string ending with a given string.

Parameters:
aStringThe string to search for. This value must not be nil.

This matcher first checks whether the evaluated object is a string. If so, it checks if aString matches the ending characters of the evaluated object.

Example:

endsWith("bar")

will match "foobar".

(In the event of a name clash, don't #define HC_SHORTHAND and use the synonym HC_endsWith instead.)

equalToIgnoringCase(aString) - Matches if object is a string equal to a given string, ignoring case differences.

Parameters:
aStringThe string to compare against as the expected value. This value must not be nil.

This matcher first checks whether the evaluated object is a string. If so, it compares it with aString, ignoring differences of case.

Example:

equalToIgnoringCase("hello world")

will match "heLLo WorlD".

(In the event of a name clash, don't #define HC_SHORTHAND and use the synonym HC_equalToIgnoringCase instead.)

equalToIgnoringWhiteSpace(aString) - Matches if object is a string equal to a given string, ignoring differences in whitespace.

Parameters:
aStringThe string to compare against as the expected value. This value must not be nil.

This matcher first checks whether the evaluated object is a string. If so, it compares it with aString, ignoring differences in runs of whitespace.

Example:

equalToIgnoringWhiteSpace("hello world")

will match

"hello   world" 

(In the event of a name clash, don't #define HC_SHORTHAND and use the synonym HC_equalToIgnoringWhiteSpace instead.)

#define startsWith   HC_startsWith

startsWith(aString) - Matches if object is a string starting with a given string.

Parameters:
aStringThe string to search for. This value must not be nil.

This matcher first checks whether the evaluated object is a string. If so, it checks if aString matches the beginning characters of the evaluated object.

Example:

endsWith("foo")

will match "foobar".

(In the event of a name clash, don't #define HC_SHORTHAND and use the synonym HC_startsWith instead.)

stringContainsInOrder(firstString, ...) - Matches if object is a string containing a given list of substrings in relative order.

Parameters:
firstString,...A comma-separated list of strings ending with nil.

This matcher first checks whether the evaluated object is a string. If so, it checks whether it contains a given list of strings, in relative order to each other. The searches are performed starting from the beginning of the evaluated string.

Example:

stringContainsInOrder("bc", @"fg", @"jkl", nil)

will match "abcdefghijklm".

(In the event of a name clash, don't #define HC_SHORTHAND and use the synonym HC_stringContainsInOrder instead.)