diff --git a/Tests/GRDBTests/AnyCursorTests.swift b/Tests/GRDBTests/AnyCursorTests.swift index 41cabf9b6..611bf94c4 100644 --- a/Tests/GRDBTests/AnyCursorTests.swift +++ b/Tests/GRDBTests/AnyCursorTests.swift @@ -42,12 +42,13 @@ class AnyCursorTests: GRDBTestCase { } func testAnyCursorFromCursor() { - var i = 0 let base = IteratorCursor([0, 1]) + // This helper function makes sure AnyCursor initializer accepts any cursor, + // and not only IteratorCursor: func makeAnyCursor(_ cursor: C) -> AnyCursor where C.Element == Int { return AnyCursor(cursor) } - let cursor = makeAnyCursor(base) + let cursor = AnyCursor(base) XCTAssertEqual(try cursor.next()!, 0) XCTAssertEqual(try cursor.next()!, 1) XCTAssertTrue(try cursor.next() == nil) // end diff --git a/Tests/GRDBTests/DatabaseValueConvertibleFetchTests.swift b/Tests/GRDBTests/DatabaseValueConvertibleFetchTests.swift index 61e596324..1e41287a2 100644 --- a/Tests/GRDBTests/DatabaseValueConvertibleFetchTests.swift +++ b/Tests/GRDBTests/DatabaseValueConvertibleFetchTests.swift @@ -31,7 +31,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { func testFetchCursor() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: C) throws where C.Element == Fetched { + func test(_ cursor: DatabaseValueCursor) throws { XCTAssertEqual(try cursor.next()!.int, 1) XCTAssertEqual(try cursor.next()!.int, 2) XCTAssertTrue(try cursor.next() == nil) // end @@ -61,7 +61,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { let customError = NSError(domain: "Custom", code: 0xDEAD) dbQueue.add(function: DatabaseFunction("throw", argumentCount: 0, pure: true) { _ in throw customError }) try dbQueue.inDatabase { db in - func test(_ cursor: C, sql: String) throws where C.Element == Fetched { + func test(_ cursor: DatabaseValueCursor, sql: String) throws { do { _ = try cursor.next() XCTFail() @@ -102,7 +102,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { func testFetchCursorCompilationFailure() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: @autoclosure () throws -> C, sql: String) throws where C.Element == Fetched { + func test(_ cursor: @autoclosure () throws -> DatabaseValueCursor, sql: String) throws { do { _ = try cursor() XCTFail() @@ -366,7 +366,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { func testOptionalFetchCursor() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: C) throws where C.Element == Fetched? { + func test(_ cursor: NullableDatabaseValueCursor) throws { XCTAssertEqual(try cursor.next()!!.int, 1) XCTAssertTrue(try cursor.next()! == nil) XCTAssertTrue(try cursor.next() == nil) // end @@ -396,7 +396,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { let customError = NSError(domain: "Custom", code: 0xDEAD) dbQueue.add(function: DatabaseFunction("throw", argumentCount: 0, pure: true) { _ in throw customError }) try dbQueue.inDatabase { db in - func test(_ cursor: C, sql: String) throws where C.Element == Fetched? { + func test(_ cursor: NullableDatabaseValueCursor, sql: String) throws { do { _ = try cursor.next() XCTFail() @@ -437,7 +437,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase { func testOptionalFetchCursorCompilationFailure() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: @autoclosure () throws -> C, sql: String) throws where C.Element == Fetched? { + func test(_ cursor: @autoclosure () throws -> NullableDatabaseValueCursor, sql: String) throws { do { _ = try cursor() XCTFail() diff --git a/Tests/GRDBTests/RowConvertibleTests.swift b/Tests/GRDBTests/RowConvertibleTests.swift index 97589a7d4..367eaddb6 100644 --- a/Tests/GRDBTests/RowConvertibleTests.swift +++ b/Tests/GRDBTests/RowConvertibleTests.swift @@ -31,7 +31,7 @@ class RowConvertibleTests: GRDBTestCase { func testFetchCursor() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: C) throws where C.Element == Fetched { + func test(_ cursor: RecordCursor) throws { var record = try cursor.next()! XCTAssertEqual(record.firstName, "Arthur") XCTAssertEqual(record.lastName, "Martin") @@ -65,7 +65,7 @@ class RowConvertibleTests: GRDBTestCase { let customError = NSError(domain: "Custom", code: 0xDEAD) dbQueue.add(function: DatabaseFunction("throw", argumentCount: 0, pure: true) { _ in throw customError }) try dbQueue.inDatabase { db in - func test(_ cursor: C, sql: String) throws where C.Element == Fetched { + func test(_ cursor: RecordCursor, sql: String) throws { do { _ = try cursor.next() XCTFail() @@ -106,7 +106,7 @@ class RowConvertibleTests: GRDBTestCase { func testFetchCursorCompilationFailure() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: @autoclosure () throws -> C, sql: String) throws where C.Element == Fetched { + func test(_ cursor: @autoclosure () throws -> RecordCursor, sql: String) throws { do { _ = try cursor() XCTFail() diff --git a/Tests/GRDBTests/StatementColumnConvertibleFetchTests.swift b/Tests/GRDBTests/StatementColumnConvertibleFetchTests.swift index 944f544e8..5b3cdcb9d 100644 --- a/Tests/GRDBTests/StatementColumnConvertibleFetchTests.swift +++ b/Tests/GRDBTests/StatementColumnConvertibleFetchTests.swift @@ -86,7 +86,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { func testFetchCursor() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: C) throws where C.Element == Fetched { + func test(_ cursor: ColumnCursor) throws { var i = try cursor.next()! XCTAssertEqual(i.int, 1) XCTAssertTrue(i.fast) @@ -120,7 +120,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { let customError = NSError(domain: "Custom", code: 0xDEAD) dbQueue.add(function: DatabaseFunction("throw", argumentCount: 0, pure: true) { _ in throw customError }) try dbQueue.inDatabase { db in - func test(_ cursor: C, sql: String) throws where C.Element == Fetched { + func test(_ cursor: ColumnCursor, sql: String) throws { do { _ = try cursor.next() XCTFail() @@ -161,7 +161,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { func testFetchCursorCompilationFailure() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: @autoclosure () throws -> C, sql: String) throws where C.Element == Fetched { + func test(_ cursor: @autoclosure () throws -> ColumnCursor, sql: String) throws { do { _ = try cursor() XCTFail() @@ -426,7 +426,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { func testOptionalFetchCursor() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: C) throws where C.Element == Fetched? { + func test(_ cursor: NullableColumnCursor) throws { let i = try cursor.next()! XCTAssertEqual(i!.int, 1) XCTAssertTrue(i!.fast) @@ -456,7 +456,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase { func testOptionalFetchCursorCompilationFailure() throws { let dbQueue = try makeDatabaseQueue() try dbQueue.inDatabase { db in - func test(_ cursor: @autoclosure () throws -> C, sql: String) throws where C.Element == Fetched? { + func test(_ cursor: @autoclosure () throws -> NullableColumnCursor, sql: String) throws { do { _ = try cursor() XCTFail()