Skip to content

Commit

Permalink
Unit tests for line breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
tevelee committed Aug 14, 2024
1 parent b528bd0 commit 25566ab
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Tests/FlowTests/LineBreakingTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import XCTest
@testable import Flow

final class LineBreakingTests: XCTestCase {
func test_flow() throws {
// Given
let sut = FlowLineBreaker()

// When
let breakpoints = sut.wrapItemsToLines(
sizes: [10, 20, 30, 40, 20, 30],
spacings: [0, 10, 10, 10, 10, 10],
in: 80
)

// Then
XCTAssertEqual(breakpoints, [0, 3, 5, 6])
}

func test_knuth_plass() throws {
// Given
let sut = KnuthPlassLineBreaker()

// When
let breakpoints = sut.wrapItemsToLines(
sizes: [10, 20, 30, 40, 20, 30],
spacings: [0, 10, 10, 10, 10, 10],
in: 80
)

// Then
XCTAssertEqual(breakpoints, [0, 3, 4, 6])
}
}

0 comments on commit 25566ab

Please sign in to comment.