Sha256: 5928a6c95a1897459f4c5fa29ced93ba18a7e19be0126658cd2b00d87014e10b

Contents?: true

Size: 1.75 KB

Versions: 153

Compression:

Stored size: 1.75 KB

Contents

import XCTest
@testable import Allergies

class AllergiesTests: XCTestCase {

    func testBob() {

        let allergies = Allergies(34)

        XCTAssertTrue(allergies.hasAllergy(.peanuts), "Bob is allergic to peanuts")
        XCTAssertTrue(allergies.hasAllergy(.chocolate), "Bob is allergic to chocolate")
        XCTAssertFalse(allergies.hasAllergy(.cats), "Bob is not allergic to cats")
    }

    func testEggsNcats() {

        let allergies = Allergies(129)

        XCTAssertTrue(allergies.hasAllergy(.eggs))
        XCTAssertTrue(allergies.hasAllergy(.cats))
        XCTAssertFalse(allergies.hasAllergy(.chocolate))
    }

    func testNone() {
        let allergies = Allergies(0)

        XCTAssertFalse(allergies.hasAllergy(.pollen))
    }

    func testOtherAllergies() {
        let allergies = Allergies(257)

        XCTAssertTrue(allergies.hasAllergy(.eggs))
    }

    func testAll() {

        let allInt =  UInt(Array(0...7).reduce(0) { return ($0 | (1 << $1)) })
        let allergies = Allergies(allInt)

        XCTAssertTrue(allergies.hasAllergy(.eggs))
        XCTAssertTrue(allergies.hasAllergy(.peanuts))
        XCTAssertTrue(allergies.hasAllergy(.shellfish))
        XCTAssertTrue(allergies.hasAllergy(.strawberries))
        XCTAssertTrue(allergies.hasAllergy(.tomatoes))
        XCTAssertTrue(allergies.hasAllergy(.chocolate))
        XCTAssertTrue(allergies.hasAllergy(.pollen))
        XCTAssertTrue(allergies.hasAllergy(.cats))

    }

    static var allTests: [(String, (AllergiesTests) -> () throws -> Void)] {
        return [
            ("testBob", testBob),
            ("testEggsNcats", testEggsNcats),
            ("testNone", testNone),
            ("testOtherAllergies", testOtherAllergies),
            ("testAll", testAll),
        ]
    }
}

Version data entries

153 entries across 153 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.179 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.178 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.177 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.176 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.175 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.174 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.173 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.172 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.171 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.170 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.169 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.167 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.166 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.165 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.164 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.163 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.162 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.161 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.160 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift