From 25566abc0f9558027d4d7d47022b2f7abeec8826 Mon Sep 17 00:00:00 2001 From: Laszlo Teveli Date: Wed, 14 Aug 2024 23:00:00 +0200 Subject: [PATCH] Unit tests for line breaking --- Tests/FlowTests/LineBreakingTests.swift | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Tests/FlowTests/LineBreakingTests.swift diff --git a/Tests/FlowTests/LineBreakingTests.swift b/Tests/FlowTests/LineBreakingTests.swift new file mode 100644 index 00000000..264d20d8 --- /dev/null +++ b/Tests/FlowTests/LineBreakingTests.swift @@ -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]) + } +}