I am trying to test this class (Swiftris/Swifteris/Array2D.swift
):
class Array2D<T> {
let rows: Int
let columns: Int
var array: Array<T?>
init(rows: Int, columns: Int) {
self.rows = rows
self.columns = columns
array = Array<T?>(count:rows * columns, repeatedValue: nil)
}
subscript(column: Int, row: Int) -> T? {
get {
return array[(row * columns) + column]
}
set {
array[(row * columns) + column] = newValue
}
}
}
With this simple test (Swiftris/SwiftrisTests/Array2DTest.swift
):
import UIKit
import XCTest
class Array2DTest: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
func testHasRows() {
var array: Array2D = Array2D(rows: 10, columns: 15)
XCTAssertEqual(array.rows, 20, "an Array2D instance should have the correct number of rows")
}
}
It unexplainably fails to resolve Array2D:
Swifteris/SwifterisTests/Array2DTest.swift:12:20: Use of undeclared type 'Array2D'
Do I need to import my own module into my tests? This is pretty puzzling since I did the exact same thin in another project and had no trouble resolving classes under test.