diff --git a/GRDB/Core/Cursor.swift b/GRDB/Core/Cursor.swift index b67094c92..edf093ef9 100644 --- a/GRDB/Core/Cursor.swift +++ b/GRDB/Core/Cursor.swift @@ -177,8 +177,6 @@ extension Cursor { /// - Returns: A cursor starting after the specified number of /// elements. public func dropFirst(_ n: Int) -> DropFirstCursor { - // TODO: test that [1,2,3,4].dropFirst(1).dropFirst(1) is equivalent to - // [1,2,3,4].dropFirst(2). return DropFirstCursor(self, limit: n) } diff --git a/Tests/GRDBTests/DropFirstCursorTests.swift b/Tests/GRDBTests/DropFirstCursorTests.swift index ae6110ad7..d118418da 100644 --- a/Tests/GRDBTests/DropFirstCursorTests.swift +++ b/Tests/GRDBTests/DropFirstCursorTests.swift @@ -47,4 +47,15 @@ class DropFirstCursorTests: GRDBTestCase { XCTFail() } } + + func testDropFirstChain() throws { + let base = IteratorCursor([1, 2, 3, 4, 5]) + let cursor = base.dropFirst(1).dropFirst(1) + try XCTAssertEqual(cursor.next()!, 3) + try XCTAssertEqual(cursor.next()!, 4) + try XCTAssertEqual(cursor.next()!, 5) + XCTAssertTrue(try cursor.next() == nil) // end + XCTAssertTrue(try cursor.next() == nil) // past the end + } + }