Sha256: 43e14a7063415aa5cdb2f9a105745fef36c939c93219dceaebda0a8d19db1748

Contents?: true

Size: 1.63 KB

Versions: 325

Compression:

Stored size: 1.63 KB

Contents

import XCTest
@testable import Hexadecimal

class HexadecimalTests: XCTestCase {

    func testHex1IsDecimal1() {
        XCTAssertEqual(1, Int(Hexadecimal("1")))
    }

    func testHexCIsDecimal12() {
        XCTAssertEqual(12, Int(Hexadecimal("c")))
    }

    func testHex10IsDecimal16() {
        XCTAssertEqual(16, Int(Hexadecimal("10")))
    }

    func testHexAFIsDecimal175() {
        XCTAssertEqual(175, Int(Hexadecimal("af")))
    }

    func testHex100IsDecimal256() {
        XCTAssertEqual(256, Int(Hexadecimal("100")))
    }

    func testHex19aceIsDecimal105166() {
        XCTAssertEqual(105_166, Int(Hexadecimal("19ace")))
    }

    func testInvalidHexIsNil() {
        XCTAssertNil(Int(Hexadecimal("carrot")))
    }

    func testBlack() {
        XCTAssertEqual(0, Int(Hexadecimal("000000")))
    }

    func testWhite() {
        XCTAssertEqual(16_777_215, Int(Hexadecimal("ffffff")))
    }

    func testYellow() {
        XCTAssertEqual(16_776_960, Int(Hexadecimal("ffff00")))
    }

    static var allTests: [(String, (HexadecimalTests) -> () throws -> Void)] {
        return [
            ("testHex1IsDecimal1", testHex1IsDecimal1),
            ("testHexCIsDecimal12", testHexCIsDecimal12),
            ("testHex10IsDecimal16", testHex10IsDecimal16),
            ("testHexAFIsDecimal175", testHexAFIsDecimal175),
            ("testHex100IsDecimal256", testHex100IsDecimal256),
            ("testHex19aceIsDecimal105166", testHex19aceIsDecimal105166),
            ("testInvalidHexIsNil", testInvalidHexIsNil),
            ("testBlack", testBlack),
            ("testWhite", testWhite),
            ("testYellow", testYellow),
        ]
    }
}

Version data entries

325 entries across 325 versions & 1 rubygems

Version Path
trackler-2.0.6.20 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.0.6.19 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.0.6.18 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.0.6.17 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.0.6.16 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift