diff --git a/Tests/SwiftAlgorithmsTests/AdjacentPairsTests.swift b/Tests/SwiftAlgorithmsTests/AdjacentPairsTests.swift index f4e76c9c..dbcd9d7e 100644 --- a/Tests/SwiftAlgorithmsTests/AdjacentPairsTests.swift +++ b/Tests/SwiftAlgorithmsTests/AdjacentPairsTests.swift @@ -73,22 +73,43 @@ final class AdjacentPairsTests: XCTestCase { XCTAssertEqualSequences(pairs, [], by: ==) } + func testZeroElementsWrapping() { + let pairs = (0..<0).adjacentPairs(wrapping: true) + XCTAssertEqual(pairs.startIndex, pairs.endIndex) + XCTAssertEqualSequences(pairs, [], by: ==) + } + func testOneElement() { let pairs = (0..<1).adjacentPairs() XCTAssertEqual(pairs.startIndex, pairs.endIndex) XCTAssertEqualSequences(pairs, [], by: ==) } + func testOneElementWrapping() { + let pairs = (0..<1).adjacentPairs(wrapping: true) + XCTAssertEqualSequences(pairs, [(0, 0)], by: ==) + } + func testTwoElements() { let pairs = (0..<2).adjacentPairs() XCTAssertEqualSequences(pairs, [(0, 1)], by: ==) } + func testTwoElementsWrapping() { + let pairs = (0..<2).adjacentPairs(wrapping: true) + XCTAssertEqualSequences(pairs, [(0, 1), (1, 0)], by: ==) + } + func testThreeElements() { let pairs = (0..<3).adjacentPairs() XCTAssertEqualSequences(pairs, [(0, 1), (1, 2)], by: ==) } + func testThreeElementsWrapping() { + let pairs = (0..<3).adjacentPairs(wrapping: true) + XCTAssertEqualSequences(pairs, [(0, 1), (1, 2), (2, 0)], by: ==) + } + func testManyElements() { for n in 4...100 { let pairs = (0..