Skip to content

Commit

Permalink
move assertBufferState helper into testing package
Browse files Browse the repository at this point in the history
  • Loading branch information
DivineDominion committed Jun 11, 2024
1 parent 0303e14 commit 58efbb6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
18 changes: 18 additions & 0 deletions Sources/DeclarativeTextKitTesting/assertBufferState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright © 2024 Christian Tietze. All rights reserved. Distributed under the MIT License.

import XCTest
import DeclarativeTextKit

public func assertBufferState(
_ buffer: Buffer,
_ expectedDescription: String,
_ message: @autoclosure () -> String = "",
file: StaticString = #file, line: UInt = #line
) {
XCTAssertEqual(
MutableStringBuffer(wrapping: buffer).description,
expectedDescription,
message(),
file: file, line: line
)
}
1 change: 0 additions & 1 deletion Tests/DeclarativeTextKitTests/BufferWordRangeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import XCTest
@testable import DeclarativeTextKit
import DeclarativeTextKitTesting

/// Shoveling-operator for dictionary concatenation or merging.
fileprivate func << <Key, Value>(
Expand Down
1 change: 0 additions & 1 deletion Tests/DeclarativeTextKitTests/ConditionalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import XCTest
import DeclarativeTextKit
import DeclarativeTextKitTesting

final class ConditionalTests: XCTestCase {
func testConditionalSequences() throws {
Expand Down
15 changes: 1 addition & 14 deletions Tests/DeclarativeTextKitTests/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import XCTest
@testable import DeclarativeTextKit
@_exported import DeclarativeTextKitTesting // So we don't have to import all the helpers everywhere.

#if os(macOS)
import AppKit
Expand All @@ -13,20 +14,6 @@ func textView(_ string: String) -> NSTextViewBuffer {
}
#endif

func assertBufferState(
_ buffer: Buffer,
_ expectedDescription: String,
_ message: @autoclosure () -> String = "",
file: StaticString = #file, line: UInt = #line
) {
XCTAssertEqual(
MutableStringBuffer(wrapping: buffer).description,
expectedDescription,
message(),
file: file, line: line
)
}

func assertThrows<T, E: Error & Equatable>(
_ expression: @autoclosure () throws -> T,
error: E,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import XCTest
import DeclarativeTextKit
import DeclarativeTextKitTesting

final class BufferWithSelectionFromStringTests: XCTestCase {
func testBufferFromPlainString() throws {
Expand Down
1 change: 0 additions & 1 deletion Tests/DeclarativeTextKitTests/ScopedBufferSliceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import XCTest
@testable import DeclarativeTextKit
import DeclarativeTextKitTesting

final class ScopedBufferSliceTests: XCTestCase {
let availableRange = Buffer.Range(location: 3, length: 3)
Expand Down

0 comments on commit 58efbb6

Please sign in to comment.