forked from Quick/Nimble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatchTest.swift
36 lines (30 loc) · 1.03 KB
/
MatchTest.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import XCTest
import Nimble
final class MatchTest: XCTestCase {
func testMatchPositive() {
expect("11:14").to(match("\\d{2}:\\d{2}"))
}
func testMatchNegative() {
expect("hello").toNot(match("\\d{2}:\\d{2}"))
}
func testMatchPositiveMessage() {
let message = "expected to match <\\d{2}:\\d{2}>, got <hello>"
failsWithErrorMessage(message) {
expect("hello").to(match("\\d{2}:\\d{2}"))
}
}
func testMatchNegativeMessage() {
let message = "expected to not match <\\d{2}:\\d{2}>, got <11:14>"
failsWithErrorMessage(message) {
expect("11:14").toNot(match("\\d{2}:\\d{2}"))
}
}
func testMatchNils() {
failsWithErrorMessageForNil("expected to match <\\d{2}:\\d{2}>, got <nil>") {
expect(nil as String?).to(match("\\d{2}:\\d{2}"))
}
failsWithErrorMessageForNil("expected to not match <\\d{2}:\\d{2}>, got <nil>") {
expect(nil as String?).toNot(match("\\d{2}:\\d{2}"))
}
}
}