Count

public struct Count: Countable, ExpressibleByIntegerLiteral

Count object. 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 init with closure, to specify matching rule like: Count() { return ... }
  3. Using one of predefined rules, for example:
    • .never
    • .atLeastOnce
    • .in(range: 0…3)
    • .in(range: 1..<3)
    • .in(range: 7…)
    • .more(than: 2)
    • .moreOrEqual(to: 3)
    • .less(than: 2)
    • .lessOrEqual(to: 1)
  • Creates new count instance, matching specific count

    Declaration

    Swift

    public init(integerLiteral value: IntegerLiteralType)

    Parameters

    value

    Exact count value

  • Creates new count instance, with given way of checking, whether count is right or not

    Declaration

    Swift

    public init(match: @escaping (Int) -> Bool)

    Parameters

    match

    Count matching closure

  • 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

  • Count should be exactly 0

    Declaration

    Swift

    public static var never: Count
  • Count should be 1 or more

    Declaration

    Swift

    public static var atLeastOnce: Count
  • Count should be within given range

    Declaration

    Swift

    public static func `in`(range: CountableRange<Int>) -> Count

    Parameters

    range

    Valid range

    Return Value

    Count instance

  • Count should be within given range

    Declaration

    Swift

    public static func `in`(range: CountableClosedRange<Int>) -> Count

    Parameters

    range

    Valid range

    Return Value

    Count instance

  • Count should be within given range

    Declaration

    Swift

    public static func `in`(range: CountablePartialRangeFrom<Int>) -> Count

    Parameters

    range

    Valid range

    Return Value

    Count instance

  • Count should be more than given one

    Declaration

    Swift

    public static func more(than: Int) -> Count

    Parameters

    than

    Everything bigger than that is enough

    Return Value

    Count instance

  • Count should be more or equal to given one

    Declaration

    Swift

    public static func moreOrEqual(to: Int) -> Count

    Parameters

    to

    Everything that is more or equal is enough

    Return Value

    Count instance

  • Count should be less than given one

    Declaration

    Swift

    public static func less(than: Int) -> Count

    Parameters

    than

    Everyting less is enough

    Return Value

    Count instance

  • Count should be less or equal to given one

    Declaration

    Swift

    public static func lessOrEqual(to: Int) -> Count

    Parameters

    to

    Everything equal or less is enough

    Return Value

    Count instance