OCHamcrest
|
Matchers that decorate other matchers for better expression.
Defines | |
#define | describedAs HC_describedAs |
describedAs(description, matcher, ...) - Adds custom failure description to a given matcher. | |
#define | is HC_is |
is(aMatcher) - Decorates another matcher, or provides a shortcut to the frequently used is(equalTo(x)). |
Matchers that decorate other matchers for better expression.
#define describedAs HC_describedAs |
describedAs(description, matcher, ...) - Adds custom failure description to a given matcher.
description | Overrides the matcher's description. |
matcher,... | The matcher to satisfy, followed by a comma-separated list of substitution values ending with nil . |
The description may contain substitution placeholders %0, %1, etc. These will be replaced by any values that follow the matcher.
(In the event of a name clash, don't #define HC_SHORTHAND
and use the synonym HC_describedAs
instead.)
is(aMatcher) - Decorates another matcher, or provides a shortcut to the frequently used is(equalTo(x)).
aMatcher | The matcher to satisfy, or an expected value for equalTo matching. |
This matcher compares the evaluated object to the given matcher.
If the aMatcher argument is a matcher, its behavior is retained, but the test may be more expressive. For example:
assertThatInt(value, equalToInt(5))
assertThatInt(value, is(equalToInt(5)))
If the aMatcher argument is not a matcher, it is wrapped in an equalTo matcher. This makes the following statements equivalent:
assertThat(cheese, equalTo(smelly))
assertThat(cheese, is(equalTo(smelly)))
assertThat(cheese, is(smelly))
Choose the style that makes your expression most readable. This will vary depending on context.
(In the event of a name clash, don't #define HC_SHORTHAND
and use the synonym HC_is
instead.)