Files
Nate Cook 66ae806bbe Enable CI format check (#253)
* Incorporate swift-format formatting fixes
* Resolve linting issues
* Doc edits, mostly to fix linter-identified issues
* Early exit improvements
* Indentation fixes
* Line lengths to 80 maximum
* Implement case binding rule, plus argument line break improvements
* Implement NoForceUnwrap rule
* Format the tests, as well
* Stop masquerading as XCTest
2025-03-05 09:11:17 -06:00

35 lines
1.1 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Algorithms open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
import Algorithms
import XCTest
final class IndexedTests: XCTestCase {
func testIndexed() {
let s = "ABCDEFGHIJKLMNOP"
let si = s.indexed()
XCTAssertEqual(s.startIndex, si.first!.index)
XCTAssertEqual("A", si.first!.element)
XCTAssertEqual(s.index(before: s.endIndex), si.last!.index)
XCTAssertEqual("P", si.last!.element)
let indexOfG = si.first(where: { $0.element == "G" })!.index
XCTAssertEqual("G", s[indexOfG])
let indexOfI = si.last(where: { $0.element == "I" })!.index
XCTAssertEqual("I", s[indexOfI])
}
func testIndexedLazy() {
requireLazyCollection("ABCD".lazy.indexed())
}
}