1
exercism fetch swift perfect-numbers

Tests/LinuxMain.swift

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

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

Tests/PerfectNumbersTests/PerfectNumbersTests.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
import XCTest
@testable import PerfectNumbers

class PerfectNumbersTests: XCTestCase {
    func testPerfect() {
        let numberClassifier = NumberClassifier(number: 6)
        XCTAssertEqual([.perfect], [numberClassifier.classification])
    }

    func testPerfectAgain() {
        let numberClassifier = NumberClassifier(number: 28)
        XCTAssertEqual([.perfect], [numberClassifier.classification])
    }

    func testDeficient() {
        let numberClassifier = NumberClassifier(number: 13)
        XCTAssertEqual([.deficient], [numberClassifier.classification])

    }

    func testAbundant() {
        let numberClassifier = NumberClassifier(number: 12)
        XCTAssertEqual([.abundant], [numberClassifier.classification])
    }

    static var allTests: [(String, (PerfectNumbersTests) -> () throws -> Void)] {
        return [
            ("testPerfect", testPerfect),
            ("testPerfectAgain", testPerfectAgain),
            ("testDeficient", testDeficient),
            ("testAbundant", testAbundant),
        ]
    }
}