4916480f4e
That was easier than I feared.
38 lines
1.2 KiB
Swift
38 lines
1.2 KiB
Swift
//
|
|
// Array_Tests.swift
|
|
// SwiftShell2
|
|
//
|
|
// Created by Kåre Morstøl on 20.09.15.
|
|
//
|
|
//
|
|
|
|
import XCTest
|
|
@testable import SwiftShell
|
|
|
|
class Array_Tests: XCTestCase {
|
|
|
|
// comparing as strings because XCTAssertEqual doesn't support [Any]
|
|
|
|
func testAnyArrayFlattenAFlatOne () {
|
|
XCTAssertEqual( ([1,"2"] as [Any]).flatten().description, "[1, \"2\"]")
|
|
XCTAssertEqual( (["1","2"] as [Any]).flatten().description, ["1", "2"].description)
|
|
XCTAssertEqual( ([1,2] as [Any]).flatten().description, [1,2].description)
|
|
}
|
|
|
|
func testAnyArrayFlattenABumpyOne () {
|
|
let intarray = [1,2]
|
|
XCTAssertEqual( ([intarray] as [Any]).flatten().description, [1,2].description)
|
|
XCTAssertEqual( (["1",[2,3]] as [Any]).flatten().description, "[\"1\", 2, 3]")
|
|
|
|
let stringarray = ["one", "two"]
|
|
XCTAssertEqual( ([stringarray, "three"] as [Any]).flatten().description, ["one","two","three"].description)
|
|
XCTAssertEqual( ([stringarray, 3] as [Any]).flatten().description, (["one","two",3] as [Any]).description)
|
|
}
|
|
|
|
func testAnyArrayFlattenAVeryBumpyOne () {
|
|
let intarray = [1,2]
|
|
XCTAssertEqual( ([[intarray]] as [Any]).flatten().description, intarray.description)
|
|
XCTAssertEqual( (["1",[2,[3] as Any]] as [Any]).flatten().description, "[\"1\", 2, 3]")
|
|
}
|
|
}
|