Count

public enum Count : ExpressibleByIntegerLiteral
extension Count: CustomStringConvertible
extension Count: Countable

Count enum. Use it for all Verify features, when checking how many times something happened.

There are three ways of using it:

  1. Explicit literal - you can pass 0, 1, 2 … to verify exact number
  2. Using predefined .custom, to specify custom matching rule.
  3. Using one of predefined rules, for example:
    • .atLeastOnce
    • .exactly(1)
    • .from(2, to: 4)
    • .less(than: 2)
    • .lessOrEqual(to: 1)
    • .more(than: 2)
    • .moreOrEqual(to: 3)
    • .never
  • Count matching closure

    Declaration

    Swift

    public typealias CustomMatchingClosure = (_ value: Int) -> Bool
  • [Internal] Count is represented by integer literals, with type Int

    Declaration

    Swift

    public typealias IntegerLiteralType = Int
  • Called at least once

    Declaration

    Swift

    case atLeastOnce
  • Called exactly once

    Declaration

    Swift

    case once
  • Custom count resolving closure

    Declaration

    Swift

    case custom(CustomMatchingClosure)
  • Called exactly n times

    Declaration

    Swift

    case exactly(Int)
  • Called in a…b range

    Declaration

    Swift

    case from(Int, to: Int)
  • Called less than n times

    Declaration

    Swift

    case less(than: Int)
  • Called less than ot equal to n times

    Declaration

    Swift

    case lessOrEqual(to: Int)
  • Called more than n times

    Declaration

    Swift

    case more(than: Int)
  • Called more than ot equal to n times

    Declaration

    Swift

    case moreOrEqual(to: Int)
  • Never called

    Declaration

    Swift

    case never
  • Creates new count instance, matching specific count

    Declaration

    Swift

    public init(integerLiteral value: IntegerLiteralType)

    Parameters

    value

    Exact count value

CustomStringConvertible

  • Human readable description

    Declaration

    Swift

    public var description: String { get }

Countable

  • Returns whether given count matches countable case.

    Declaration

    Swift

    public func matches(_ count: Int) -> Bool

    Parameters

    count

    Given count

    Return Value

    true, if it is within boundaries, false otherwise