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.2.1.98 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.97 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.96 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.95 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.94 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.93 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.92 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.91 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.90 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.89 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.88 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.87 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.86 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.85 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.84 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.83 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.82 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.81 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.80 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.79 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift