-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.swift
59 lines (49 loc) · 1.06 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Foundation
import XCTest
var argv = CommandLine.arguments
let (name, option) = (
argv.removeFirst(),
argv.first
)
switch option {
case .none:
run()
case "--test":
runTests()
case "--help":
printHelp(for: name)
case .some(let option):
printError(for: option)
printHelp(for: name)
}
func run() {
let arr1 = [
AnyEquatable(1),
AnyEquatable(1.0),
AnyEquatable(true),
AnyEquatable("1"),
]
let arr2 = [
AnyEquatable(1),
AnyEquatable(1.0),
AnyEquatable(true),
AnyEquatable("1")
]
print(String(reflecting: arr1) + " == " + String(reflecting: arr2))
print(arr1 == arr2)
}
func runTests() {
let testCases: [AnyClass] = [
AnyEquatableTests.self
]
let testSuites = testCases.map {
XCTestSuite(forTestCaseClass: $0)
}
testSuites.forEach { $0.run() }
}
func printHelp(for name: String) {
print("usage: \(name) [--test] [--help]")
}
func printError(for option: String) {
print("error: unknown option `\(option)`")
}