diff --git a/Sources/RopeModule/Rope/Operations/Rope+Remove.swift b/Sources/RopeModule/Rope/Operations/Rope+Remove.swift index f29aa6f8..7a19183a 100644 --- a/Sources/RopeModule/Rope/Operations/Rope+Remove.swift +++ b/Sources/RopeModule/Rope/Operations/Rope+Remove.swift @@ -44,7 +44,7 @@ extension Rope._Node { } extension Rope { - mutating func remove( + public mutating func remove( at position: Int, in metric: some RopeMetric ) -> Element { diff --git a/Tests/RopeModuleTests/TestBString2.swift b/Tests/RopeModuleTests/TestBString2.swift deleted file mode 100644 index cc650b38..00000000 --- a/Tests/RopeModuleTests/TestBString2.swift +++ /dev/null @@ -1,65 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Collections open source project -// -// Copyright (c) 2023 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 -// -//===----------------------------------------------------------------------===// - -#if swift(>=5.8) && DEBUG -import _CollectionsTestSupport -import XCTest -@testable import _RopeModule - -@available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) -class TestBigString2: CollectionTestCase { - override var isAvailable: Bool { isRunningOnSwiftStdlib5_8 } - - func testUTF8View() { - let str = BigString(shortSample) - checkBidirectionalCollection(str.utf8, expectedContents: shortSample.utf8) - } - - func testUTF16View() { - let str = BigString(shortSample) - checkBidirectionalCollection(str.utf16, expectedContents: shortSample.utf16) - } - - func testUnicodeScalarView() { - let str = BigString(shortSample) - checkBidirectionalCollection(str.unicodeScalars, expectedContents: shortSample.unicodeScalars) - } - - func testCharacterView() { - let str = BigString(shortSample) - checkBidirectionalCollection(str, expectedContents: shortSample) - } - - func testHashable_Characters() { - let classes: [[BigString]] = [ - ["Cafe\u{301}", "Café"], - ["Foo\u{301}\u{327}", "Foo\u{327}\u{301}"], - ["Foo;bar", "Foo\u{37e}bar"], - ] - checkHashable(equivalenceClasses: classes) - } - - func testHashable_Scalars() { - let classes: [BigString] = [ - "Cafe\u{301}", - "Café", - "Foo\u{301}\u{327}", - "Foo\u{327}\u{301}", - "Foo;bar", - "Foo\u{37e}bar", - ] - checkHashable(equivalenceClasses: classes.map { [$0.unicodeScalars] }) - checkHashable(equivalenceClasses: classes.map { [$0.utf8] }) - checkHashable(equivalenceClasses: classes.map { [$0.utf16] }) - } -} - -#endif diff --git a/Tests/RopeModuleTests/TestBString.swift b/Tests/RopeModuleTests/TestBigString.swift similarity index 96% rename from Tests/RopeModuleTests/TestBString.swift rename to Tests/RopeModuleTests/TestBigString.swift index 45470229..2b36ee1c 100644 --- a/Tests/RopeModuleTests/TestBString.swift +++ b/Tests/RopeModuleTests/TestBigString.swift @@ -36,7 +36,6 @@ class TestBigString: CollectionTestCase { XCTAssertLessThanOrEqual(min, max) #if !DEBUG // Debug builds have smaller nodes - // We want big strings to hold at least as many UTF-8 code units as a regular String. // We want big strings to hold at least as many UTF-8 code units as a regular String. XCTAssertGreaterThanOrEqual(min, 1 << 48) #endif @@ -78,7 +77,7 @@ class TestBigString: CollectionTestCase { func test_string_conversion() { let big = BigString(sampleString) - + big._invariantCheck() XCTAssertEqual(big.count, sampleString.count) XCTAssertEqual(big.unicodeScalars.count, sampleString.unicodeScalars.count) @@ -88,7 +87,50 @@ class TestBigString: CollectionTestCase { let flat = String(big) XCTAssertEqual(flat, sampleString) } - + + func testUTF8View() { + let str = BigString(shortSample) + checkBidirectionalCollection(str.utf8, expectedContents: shortSample.utf8) + } + + func testUTF16View() { + let str = BigString(shortSample) + checkBidirectionalCollection(str.utf16, expectedContents: shortSample.utf16) + } + + func testUnicodeScalarView() { + let str = BigString(shortSample) + checkBidirectionalCollection(str.unicodeScalars, expectedContents: shortSample.unicodeScalars) + } + + func testCharacterView() { + let str = BigString(shortSample) + checkBidirectionalCollection(str, expectedContents: shortSample) + } + + func testHashable_Characters() { + let classes: [[BigString]] = [ + ["Cafe\u{301}", "Café"], + ["Foo\u{301}\u{327}", "Foo\u{327}\u{301}"], + ["Foo;bar", "Foo\u{37e}bar"], + ] + checkHashable(equivalenceClasses: classes) + } + + func testHashable_Scalars() { + let classes: [BigString] = [ + "Cafe\u{301}", + "Café", + "Foo\u{301}\u{327}", + "Foo\u{327}\u{301}", + "Foo;bar", + "Foo\u{37e}bar", + ] + checkHashable(equivalenceClasses: classes.map { [$0.unicodeScalars] }) + checkHashable(equivalenceClasses: classes.map { [$0.utf8] }) + checkHashable(equivalenceClasses: classes.map { [$0.utf16] }) + } + @discardableResult func checkCharacterIndices( _ flat: String, diff --git a/Tests/RopeModuleTests/TestRope.swift b/Tests/RopeModuleTests/TestRope.swift index d5e7e098..0c3f40e3 100644 --- a/Tests/RopeModuleTests/TestRope.swift +++ b/Tests/RopeModuleTests/TestRope.swift @@ -9,8 +9,7 @@ // //===----------------------------------------------------------------------===// -#if DEBUG -@testable import _RopeModule +import _RopeModule import XCTest struct Chunk: RopeElement, Equatable, CustomStringConvertible { @@ -541,4 +540,3 @@ class TestRope: XCTestCase { } } -#endif