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.180 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.179 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.178 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.177 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.176 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.175 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.174 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.173 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.172 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.171 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.170 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.169 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.167 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.166 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.165 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.164 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.163 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.162 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.161 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift
trackler-2.2.1.160 tracks/swift/exercises/hexadecimal/Tests/HexadecimalTests/HexadecimalTests.swift