Tests for Cursor.dropFirst(_:)

This commit is contained in:
Gwendal Roué committed 2018-01-28 17:13:47 +01:00
1 parent 72608fd016
commit 520bdd64e6
2 files changed
+11 -2

No files matched your search

-2
View File
@@ -177,8 +177,6 @@ extension Cursor {
/// - Returns: A cursor starting after the specified number of
/// elements.
public func dropFirst(_ n: Int) -> DropFirstCursor<Self> {
// 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)
}
@@ -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
}
}