Sha256: 64c21d9bf8031100a104229ba7f04e90f41b8bf02a4497364e4e0b6cb78aef0a

Contents?: true

Size: 1.83 KB

Versions: 13

Compression:

Stored size: 1.83 KB

Contents

import XCTest

class FlattenArrayTest: XCTestCase {

    func testFlattenIntegerArray() {

        let result: [Int] = flattenArray([1, [2, 3, 4, 5, 6, 7], 8])
        XCTAssertEqual([1, 2, 3, 4, 5, 6, 7, 8], result)
    }

    func testFlattenForFiveLevelDeepNestedList() {

        let result: [Int] = flattenArray([0, 2, [[2, 3], 8, 100, 4, [[[50]]]], -2])
        XCTAssertEqual([0, 2, 2, 3, 8, 100, 4, 50, -2], result)
    }

    func testFlattenForSixLevelDeepNestedList() {

        let result: [Int] = flattenArray([1, [2, [[3]], [4, [[5]]], 6, 7], 8])
        XCTAssertEqual([1, 2, 3, 4, 5, 6, 7, 8], result)
    }

    func testFlattenForSixLevelDeepNestedListWithNullValues() {

        let nilValue: Any? = nil
        let result: [Int] = flattenArray([0, 2, [[2, 3], 8, [[100]], nilValue, [[nilValue]]], -2])
        XCTAssertEqual([0, 2, 2, 3, 8, 100, -2], result)
    }

    func testFlattenForAllNullDeepNestedList() {

        let nilValue: Any? = nil
        let result: [Int] = flattenArray([nilValue, [[[nilValue]]], nilValue, nilValue, [[nilValue, nilValue], nilValue], nilValue])
        XCTAssertEqual([], result)
    }

    func testFlattenForStringValuesInSixLevelDeepNestedList() {

        let nilValue: Any? = nil
        let result: [String] = flattenArray(["Zero", "two", [["Two", "three"], "Eight", [["ONE HUNDRED"]], nilValue, [[nilValue]]], "minus two"])
        XCTAssertEqual(["Zero", "two", "Two", "three", "Eight", "ONE HUNDRED", "minus two"], result)

    }

    func testFlattenForDoubleValuesInFiveLevelDeepNestedList() {

        let nilValue: Any? = nil
        let result: [Double] = flattenArray([0.74896463547850123, 2.18, [[nilValue, 3.6], nilValue, 100.0, nilValue, [[[50.2]]]], -2.5])
        XCTAssertEqual([0.74896463547850123, 2.1800000000000002, 3.6000000000000001, 100.0, 50.200000000000003, -2.5], result)

    }
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
trackler-2.0.6.15 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.14 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.13 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.12 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.11 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.10 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.9 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.8 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.7 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.6 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.5 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.4 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift
trackler-2.0.6.3 tracks/swift/exercises/flatten-array/FlattenArrayTest.swift