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:
- Explicit literal - you can pass 0, 1, 2 … to verify exact number
- Using init with closure, to specify matching rule like:
Count() { return ... } - 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)
-
[Internal] Count is represented by integer literals, with type Int
Declaration
Swift
public typealias IntegerLiteralType = Int -
Creates new count instance, matching specific count
Declaration
Swift
public init(integerLiteral value: IntegerLiteralType)Parameters
valueExact 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
matchCount matching closure
-
Returns whether given count matches countable case.
Declaration
Swift
public func matches(_ count: Int) -> BoolParameters
countGiven count
Return Value
true, if it is within boundaries, false otherwise
-
Count should be exactly 0
Declaration
Swift
public static var never: Count { get } -
Count should be 1 or more
Declaration
Swift
public static var atLeastOnce: Count { get } -
Count should be within given range
Declaration
Swift
public static func `in`(range: CountableRange<Int>) -> CountParameters
rangeValid range
Return Value
Count instance
-
Count should be within given range
Declaration
Swift
public static func `in`(range: CountableClosedRange<Int>) -> CountParameters
rangeValid range
Return Value
Count instance
-
Count should be within given range
Declaration
Swift
public static func `in`(range: CountablePartialRangeFrom<Int>) -> CountParameters
rangeValid range
Return Value
Count instance
-
Count should be more than given one
Declaration
Swift
public static func more(than: Int) -> CountParameters
thanEverything 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) -> CountParameters
toEverything 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) -> CountParameters
thanEveryting less is enough
Return Value
Count instance
-
Count should be less or equal to given one
Declaration
Swift
public static func lessOrEqual(to: Int) -> CountParameters
toEverything equal or less is enough
Return Value
Count instance
View on GitHub
Count Structure Reference