robnik
1
Is something wrong with this code? I do not understand why Xcode is reporting the unit test crash.
class ArrayQueueTests : XCTestCase {
func testSanity() {
let q = ArrQue<Int>(elts: [1,2,3])
print(q.count) // crashes here
}
}
The crash message is: Thread 1: EXC_BAD_ACCESS (code=2, address=0x7fff89cff44a)
In the Swift package:
public class ArrQue<T> {
private var elts: [T]
public init(elts: [T]) {
self.elts = elts
}
public var count: Int {
return elts.count
}
}
I notice that the stack trace is also completely insane. It refers to another method in another class. Maybe the call to count was compiled to method call to another class.
I have the Swift Package open in Xcode 11.2.1. I'm running the test by clicking the arrow in the left margin next to the test method.