-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.swift
More file actions
44 lines (36 loc) · 784 Bytes
/
Copy pathExample.swift
File metadata and controls
44 lines (36 loc) · 784 Bytes
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
37
38
39
40
41
42
43
44
import Foundation
import XCTest
@_functionBuilder
class BooleanFunctionBuilder {
static func buildBlock(_ children: Bool...) -> [Bool] {
return children
}
}
public func assertTrue(@BooleanFunctionBuilder builder: () -> [Bool]) {
let expressions = builder()
expressions.forEach { XCTAssertTrue($0) }
}
public func assertFalse(@BooleanFunctionBuilder builder: () -> [Bool]) {
let expressions = builder()
expressions.forEach { XCTAssertFalse($0) }
}
// Example Usage
public class TestClass: XCTestCase {
let a = 3
let b = 4
let c = 5
func testValues() {
assertTrue {
a * a + b * b == c * c
a == 3
b == 4
c == 5
}
assertFalse {
a + b == c
a + b < c
}
}
}
// Playground
TestClass.defaultTestSuite.run()