Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjacent pairs wrapping #141

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Editor > Structure > Re-Indent
  • Loading branch information
Matt Zanchelli committed May 7, 2021
commit cc023dbd4d33712f46fc6baf0513f8f81ef24389
10 changes: 5 additions & 5 deletions Tests/SwiftAlgorithmsTests/AdjacentPairsTests.swift
Original file line number Diff line number Diff line change
@@ -45,30 +45,30 @@ final class AdjacentPairsTests: XCTestCase {
XCTAssertEqual(pairs.startIndex, pairs.endIndex)
XCTAssertEqualSequences(pairs, [], by: ==)
}

func testOneElement() {
let pairs = (0..<1).adjacentPairs()
XCTAssertEqual(pairs.startIndex, pairs.endIndex)
XCTAssertEqualSequences(pairs, [], by: ==)
}

func testTwoElements() {
let pairs = (0..<2).adjacentPairs()
XCTAssertEqualSequences(pairs, [(0, 1)], by: ==)
}

func testThreeElements() {
let pairs = (0..<3).adjacentPairs()
XCTAssertEqualSequences(pairs, [(0, 1), (1, 2)], by: ==)
}

func testManyElements() {
for n in 4...100 {
let pairs = (0..<n).adjacentPairs()
XCTAssertEqualSequences(pairs, zip(0..., 1...).prefix(n - 1), by: ==)
}
}

func testIndexTraversals() {
validateIndexTraversals(
(0..<0).adjacentPairs(),