Sha256: 4bc453f70ff70710f6c59c806f752fb7b90b97b93c703a5c19fc208bfbf22ca5

Contents?: true

Size: 1.53 KB

Versions: 78

Compression:

Stored size: 1.53 KB

Contents

import XCTest
@testable import PythagoreanTriplet

class PythagoreanTripletTests: XCTestCase {
    func testSum() {
        XCTAssertEqual(12, Triplet(3, 4, 5).sum)
    }

    func testProduct() {
        XCTAssertEqual(60, Triplet(3, 4, 5).product)
    }

    func testPythagorean() {
        XCTAssertTrue(Triplet(3, 4, 5).isPythagorean)
    }

    func testNotPythagorean() {
        XCTAssertTrue(!Triplet(5, 6, 7).isPythagorean)
    }

    func testTripletsUpTo10() {
        let triplets = Triplet.Where(maxFactor: 10)
        let products = triplets.map { $0.product }.sorted(by: <)
        XCTAssertEqual([60, 480], products)
    }

    func testTripletsFrom11UpTo20() {
        let triplets = Triplet.Where(11, maxFactor: 20)
        let products = triplets.map { $0.product }.sorted(by: <)
        XCTAssertEqual([3840], products)
    }

    func testTripletsWhereSumX() {
        let triplets = Triplet.Where( maxFactor: 100, sum: 180)
        let products = triplets.map { $0.product }.sorted(by: <)
        XCTAssertEqual([118_080, 168_480, 202_500], products)
    }

    static var allTests: [(String, (PythagoreanTripletTests) -> () throws -> Void)] {
        return [
            ("testSum", testSum),
            ("testProduct", testProduct),
            ("testPythagorean", testPythagorean),
            ("testNotPythagorean", testNotPythagorean),
            ("testTripletsUpTo10", testTripletsUpTo10),
            ("testTripletsFrom11UpTo20", testTripletsFrom11UpTo20),
            ("testTripletsWhereSumX", testTripletsWhereSumX),
        ]
    }
}

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
trackler-2.1.0.53 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.52 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.51 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.50 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.49 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.48 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.47 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.46 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.45 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.44 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.43 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.42 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.41 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.40 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.39 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.38 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.37 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.36 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.34 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift
trackler-2.1.0.33 tracks/swift/exercises/pythagorean-triplet/Tests/PythagoreanTripletTests/PythagoreanTripletTests.swift