1
exercism fetch swift pig-latin

Tests/LinuxMain.swift

1
2
3
4
5
6
import XCTest
@testable import PigLatinTests

XCTMain([
    testCase(PigLatinTests.allTests),
    ])

Tests/PigLatinTests/PigLatinTests.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import XCTest
@testable import PigLatin

class PigLatinTests: XCTestCase {
    func testWordBeginningWithA() {
        XCTAssertEqual("appleay", PigLatin.translate("apple"))
    }

    func test_otherWordBeginningE() {
        XCTAssertEqual("earay", PigLatin.translate("ear"))
    }

    func testWordBeginningWithP() {
        XCTAssertEqual("igpay", PigLatin.translate("pig"))
    }

    func testWordBeginningWithK() {
        XCTAssertEqual("oalakay", PigLatin.translate("koala"))
    }

    func testWordBeginningWithCh() {
        XCTAssertEqual("airchay", PigLatin.translate("chair"))
    }

    func testWordBeginningWithQu() {
        XCTAssertEqual("eenquay", PigLatin.translate("queen"))
    }

    func testWordWithConsonantPrecedingQu() {
        XCTAssertEqual("aresquay", PigLatin.translate("square"))
    }

    func testWordBeginningWithTh() {
        XCTAssertEqual("erapythay", PigLatin.translate("therapy"))
    }

    func testWordBeginningWithThr() {
        XCTAssertEqual("ushthray", PigLatin.translate("thrush"))
    }

    func testWordBeginningWithSch() {
        XCTAssertEqual("oolschay", PigLatin.translate("school"))
    }

    func testWordBeginningWithYe() {
        XCTAssertEqual("ellowyay", PigLatin.translate("yellow"))
    }

    func testWordBeginningWithYt() {
        XCTAssertEqual("yttriaay", PigLatin.translate("yttria"))
    }

    func testWordBeginningWithXe() {
        XCTAssertEqual("enonxay", PigLatin.translate("xenon"))
    }

    func testWordBeginningWithXr() {
        XCTAssertEqual("xrayay", PigLatin.translate("xray"))
    }

    func testTranslatesPhrase() {
        XCTAssertEqual("ickquay astfay unray", PigLatin.translate("quick fast run"))
    }

    static var allTests: [(String, (PigLatinTests) -> () throws -> Void)] {
        return [
            ("testWordBeginningWithA", testWordBeginningWithA),
            ("test_otherWordBeginningE", test_otherWordBeginningE),
            ("testWordBeginningWithP", testWordBeginningWithP),
            ("testWordBeginningWithK", testWordBeginningWithK),
            ("testWordBeginningWithCh", testWordBeginningWithCh),
            ("testWordBeginningWithQu", testWordBeginningWithQu),
            ("testWordWithConsonantPrecedingQu", testWordWithConsonantPrecedingQu),
            ("testWordBeginningWithTh", testWordBeginningWithTh),
            ("testWordBeginningWithThr", testWordBeginningWithThr),
            ("testWordBeginningWithSch", testWordBeginningWithSch),
            ("testWordBeginningWithYe", testWordBeginningWithYe),
            ("testWordBeginningWithYt", testWordBeginningWithYt),
            ("testWordBeginningWithXe", testWordBeginningWithXe),
            ("testWordBeginningWithXr", testWordBeginningWithXr),
            ("testTranslatesPhrase", testTranslatesPhrase),
        ]
    }
}