Sha256: b438e900c33734f26e018e2a9ea3fffd868f947965f17ab3e509bc0ee73ef069

Contents?: true

Size: 1.57 KB

Versions: 172

Compression:

Stored size: 1.57 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 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),
            ("testAll", testAll),
        ]
    }
}

Version data entries

172 entries across 172 versions & 1 rubygems

Version Path
trackler-2.2.1.25 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.24 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.23 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.22 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.21 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.20 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.19 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.18 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.17 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.16 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.15 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.14 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.13 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.12 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.11 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.10 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.9 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.8 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.7 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift
trackler-2.2.1.6 tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift