Mockingbird Documentation 0.14.0

Structure Count​Matcher

public struct CountMatcher

Checks whether a number matches some expected count.

Methods

or(_:​)

public func or(_ countMatcher: CountMatcher) -> CountMatcher

Logically combine another count matcher, passing if either matches.

Combined count matchers can be used to perform complex checks on the number of invocations received.

// Checks that n = 1 || n ≥ 42
verify(bird.fly()).wasCalled(exactly(once).or(atLeast(42)))

Parameters

count​Matcher Count​Matcher

Another count matcher to combine.

Returns

A combined count matcher.

or(_:​)

public func or(_ times: Int) -> CountMatcher

Logically combine with an exact count, passing if either matches.

Combined count matchers can be used to perform complex checks on the number of invocations received.

// Checks that n = 1 || n = 2
verify(bird.fly()).wasCalled(exactly(once).or(twice))

Parameters

times Int

An exact count to combine.

Returns

A combined count matcher.

and(_:​)

public func and(_ countMatcher: CountMatcher) -> CountMatcher

Logically combine another count matcher, only passing if both match.

Combined count matchers can be used to perform complex checks on the number of invocations received.

// Checks that n = 1 && n ≥ 42
verify(bird.fly()).wasCalled(exactly(once).and(atLeast(42)))

Parameters

count​Matcher Count​Matcher

Another count matcher to combine.

Returns

A combined count matcher.

xor(_:​)

public func xor(_ countMatcher: CountMatcher) -> CountMatcher

Logically combine another count matcher, only passing if one matches but not the other.

Combined count matchers can be used to perform complex checks on the number of invocations received.

// Checks that n ≤ 2 ⊕ n ≥ 1
verify(bird.fly()).wasCalled(atMost(twice).xor(atLeast(once)))

Parameters

count​Matcher Count​Matcher

Another count matcher to combine.

Returns

A combined count matcher.

xor(_:​)

public func xor(_ times: Int) -> CountMatcher

Logically combine an exact count, only passing if one matches but not the other.

Combined count matchers can be used to perform complex checks on the number of invocations received.

// Checks that n ≥ 1 ⊕ n = 2
verify(bird.fly()).wasCalled(atLeast(once).xor(twice))

Parameters

times Int

An exact count.

Returns

A combined count matcher.