karwa/swift-checkit
Swift-checkit is a library containing validators which exercise common protocols.
Installation
Installation is via the Swift Package Manager. Simply add the package to your Package.swift, and add "Checkit" as a dependency for your test targets:
// Package.swift
let package = Package(...
dependencies: [
.package(url: "https://github.com/karwa/swift-checkit.git", .branch("master"))
],
targets: [
.testTarget(name: "MyTests", dependencies: ["Checkit"]),
]
...
)Now all you need to write is:
// MyTests.swift
import Checkitand you're good to start using the validators. How about checking if your custom Collection really conforms to the protocol? Or whether your Sequence-constrained algorithm really handles a single-pass Sequence?
func testCollectionSemantics() {
let myCustomCollection = MyCollection(...)
CollectionChecker.check(myCustomCollection)
}
// in project:
// func myAlgorithm<S: Sequence>(with: S) { ... }
func testAlgorithm() {
SinglePassSequenceChecker.check(0..<5) { sequence in myAlgorithm(sequence) }
}Contributing
Contributions welcome! Feel free to fork/add/send PRs for new checks and checkers!
Package Metadata
Repository: karwa/swift-checkit
Default branch: master
README: README.md