From a4a3d7b91d8403775253427acc2c072d96088484 Mon Sep 17 00:00:00 2001 From: heoblitz <25315898+heoblitz@users.noreply.github.com> Date: Fri, 6 Nov 2026 23:26:04 +0900 Subject: [PATCH 1/2] Migrate core layout tests to Swift Testing --- Tests/FlexLayoutTests/FlexLayoutTests.swift | 67 +++++++------- .../FlexLayoutTests/JustifyContentTests.swift | 74 ++++++++------- .../WidthSizeContentTests.swift | 90 +++++++++++-------- 3 files changed, 130 insertions(+), 101 deletions(-) diff --git a/Tests/FlexLayoutTests/FlexLayoutTests.swift b/Tests/FlexLayoutTests/FlexLayoutTests.swift index 9d8667f..afbcabf 100644 --- a/Tests/FlexLayoutTests/FlexLayoutTests.swift +++ b/Tests/FlexLayoutTests/FlexLayoutTests.swift @@ -10,13 +10,15 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import XCTest +import Testing +import UIKit @testable import FlexLayout @MainActor -final class FlexLayoutTests: XCTestCase { +struct FlexLayoutTests { - func testRetainCycle() { + @Test + func flexDoesNotCreateRetainCycle() { weak var weakView: UIView? = nil _ = { _ in let strongView = UIView() @@ -24,11 +26,12 @@ final class FlexLayoutTests: XCTestCase { weakView = strongView }(()) - XCTAssertNil(weakView, "Creation of flex should not lead to retain cycle") + #expect(weakView == nil, "Creation of flex should not lead to retain cycle") } - func testRemoveViewDynamically() { + @Test + func removeViewDynamically() { let rootFlexContainer = UIView() rootFlexContainer.flex.addItem(UIView()) rootFlexContainer.flex.define { _ in } @@ -38,10 +41,11 @@ final class FlexLayoutTests: XCTestCase { rootFlexContainer.flex.markDirty() rootFlexContainer.flex.layout() - XCTAssertTrue(rootFlexContainer.subviews.isEmpty) + #expect(rootFlexContainer.subviews.isEmpty) } - func testLayoutPreservesNonFlexViewFrameAcrossLayouts() { + @Test + func layoutPreservesNonFlexViewFrameAcrossLayouts() { let container = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) let originalFrame = CGRect(x: 30, y: 40, width: 50, height: 60) let overlay = UIView(frame: originalFrame) @@ -53,9 +57,9 @@ final class FlexLayoutTests: XCTestCase { container.flex.layout() - XCTAssertEqual(overlay.frame, originalFrame) - XCTAssertFalse(overlay.isFlexEnabled) - XCTAssertEqual(flexView.frame, CGRect(x: 0, y: 0, width: 200, height: 20)) + #expect(overlay.frame == originalFrame) + #expect(!overlay.isFlexEnabled) + #expect(flexView.frame == CGRect(x: 0, y: 0, width: 200, height: 20)) let updatedFrame = CGRect(x: 45, y: 55, width: 65, height: 75) overlay.frame = updatedFrame @@ -63,12 +67,13 @@ final class FlexLayoutTests: XCTestCase { container.flex.layout() - XCTAssertEqual(overlay.frame, updatedFrame) - XCTAssertFalse(overlay.isFlexEnabled) - XCTAssertEqual(flexView.frame, CGRect(x: 0, y: 0, width: 300, height: 20)) + #expect(overlay.frame == updatedFrame) + #expect(!overlay.isFlexEnabled) + #expect(flexView.frame == CGRect(x: 0, y: 0, width: 300, height: 20)) } - func testLayoutPreservesNonFlexSubtreeFrames() { + @Test + func layoutPreservesNonFlexSubtreeFrames() { let container = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) container.flex.addItem().width(20).height(20) @@ -82,12 +87,13 @@ final class FlexLayoutTests: XCTestCase { container.flex.layout() - XCTAssertEqual(overlay.frame, overlayFrame) - XCTAssertEqual(child.frame, childFrame) - XCTAssertFalse(overlay.isFlexEnabled) + #expect(overlay.frame == overlayFrame) + #expect(child.frame == childFrame) + #expect(!overlay.isFlexEnabled) } - func testLayoutUpdatesSubtreeWhenInclusionChanges() { + @Test + func layoutUpdatesSubtreeWhenInclusionChanges() { let container = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) let excludedFrame = CGRect(x: 30, y: 40, width: 50, height: 60) let excludedView = UIView(frame: excludedFrame) @@ -100,28 +106,29 @@ final class FlexLayoutTests: XCTestCase { container.flex.layout() - XCTAssertEqual(excludedView.frame, excludedFrame) - XCTAssertEqual(child.frame, childFrame) - XCTAssertEqual(flexView.frame, CGRect(x: 0, y: 0, width: 20, height: 20)) + #expect(excludedView.frame == excludedFrame) + #expect(child.frame == childFrame) + #expect(flexView.frame == CGRect(x: 0, y: 0, width: 20, height: 20)) excludedView.flex.isIncludedInLayout = true container.flex.layout() - XCTAssertEqual(excludedView.frame, CGRect(x: 0, y: 0, width: 100, height: 100)) - XCTAssertEqual(child.frame, CGRect(x: 0, y: 0, width: 10, height: 10)) - XCTAssertEqual(flexView.frame, CGRect(x: 0, y: 100, width: 20, height: 20)) + #expect(excludedView.frame == CGRect(x: 0, y: 0, width: 100, height: 100)) + #expect(child.frame == CGRect(x: 0, y: 0, width: 10, height: 10)) + #expect(flexView.frame == CGRect(x: 0, y: 100, width: 20, height: 20)) excludedView.flex.isIncludedInLayout = false excludedView.frame = excludedFrame child.frame = childFrame container.flex.layout() - XCTAssertEqual(excludedView.frame, excludedFrame) - XCTAssertEqual(child.frame, childFrame) - XCTAssertEqual(flexView.frame, CGRect(x: 0, y: 0, width: 20, height: 20)) + #expect(excludedView.frame == excludedFrame) + #expect(child.frame == childFrame) + #expect(flexView.frame == CGRect(x: 0, y: 0, width: 20, height: 20)) } - func testLayoutAppliesFramesToIncludedFlexDescendants() { + @Test + func layoutAppliesFramesToIncludedFlexDescendants() { let container = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) let nestedContainer = UIView() let child = UIView() @@ -130,7 +137,7 @@ final class FlexLayoutTests: XCTestCase { container.flex.layout() - XCTAssertEqual(nestedContainer.frame, CGRect(x: 0, y: 0, width: 100, height: 100)) - XCTAssertEqual(child.frame, CGRect(x: 10, y: 10, width: 20, height: 30)) + #expect(nestedContainer.frame == CGRect(x: 0, y: 0, width: 100, height: 100)) + #expect(child.frame == CGRect(x: 10, y: 10, width: 20, height: 30)) } } diff --git a/Tests/FlexLayoutTests/JustifyContentTests.swift b/Tests/FlexLayoutTests/JustifyContentTests.swift index b98e119..fffa26f 100644 --- a/Tests/FlexLayoutTests/JustifyContentTests.swift +++ b/Tests/FlexLayoutTests/JustifyContentTests.swift @@ -11,10 +11,11 @@ // POSSIBILITY OF SUCH DAMAGE. import FlexLayout -import XCTest +import Testing +import UIKit @MainActor -final class JustifyContentTests: XCTestCase, Sendable { +struct JustifyContentTests { var viewController: UIViewController! var rootFlexContainer: UIView! @@ -23,8 +24,7 @@ final class JustifyContentTests: XCTestCase, Sendable { var cView: UIView! var dView: UIView! - override func setUp() async throws { - try await super.setUp() + init() { viewController = UIViewController() @@ -39,7 +39,8 @@ final class JustifyContentTests: XCTestCase, Sendable { } - func test_justifyContent_adjust_view_position_default() { + @Test + func justifyContentAdjustViewPositionDefault() { rootFlexContainer.flex.define { flex in flex.addItem(aView).size(20) flex.addItem(bView).size(20) @@ -47,13 +48,14 @@ final class JustifyContentTests: XCTestCase, Sendable { flex.addItem(dView).size(20) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 20.0, height: 20.0)) - XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 20.0, width: 20.0, height: 20.0)) - XCTAssertEqual(cView.frame, CGRect(x: 0.0, y: 40.0, width: 20.0, height: 20.0)) - XCTAssertEqual(dView.frame, CGRect(x: 0.0, y: 60.0, width: 20.0, height: 20.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 20.0, height: 20.0)) + #expect(bView.frame == CGRect(x: 0.0, y: 20.0, width: 20.0, height: 20.0)) + #expect(cView.frame == CGRect(x: 0.0, y: 40.0, width: 20.0, height: 20.0)) + #expect(dView.frame == CGRect(x: 0.0, y: 60.0, width: 20.0, height: 20.0)) } - func test_justifyContent_adjust_view_position_start() { + @Test + func justifyContentAdjustViewPositionStart() { rootFlexContainer.flex.justifyContent(.start).define { flex in flex.addItem(aView).size(20) flex.addItem(bView).size(20) @@ -61,13 +63,14 @@ final class JustifyContentTests: XCTestCase, Sendable { flex.addItem(dView).size(20) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 20.0, height: 20.0)) - XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 20.0, width: 20.0, height: 20.0)) - XCTAssertEqual(cView.frame, CGRect(x: 0.0, y: 40.0, width: 20.0, height: 20.0)) - XCTAssertEqual(dView.frame, CGRect(x: 0.0, y: 60.0, width: 20.0, height: 20.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 20.0, height: 20.0)) + #expect(bView.frame == CGRect(x: 0.0, y: 20.0, width: 20.0, height: 20.0)) + #expect(cView.frame == CGRect(x: 0.0, y: 40.0, width: 20.0, height: 20.0)) + #expect(dView.frame == CGRect(x: 0.0, y: 60.0, width: 20.0, height: 20.0)) } - func test_justifyContent_adjust_view_position_center() { + @Test + func justifyContentAdjustViewPositionCenter() { rootFlexContainer.flex.justifyContent(.center).define { flex in flex.addItem(aView).size(20) flex.addItem(bView).size(20) @@ -75,13 +78,14 @@ final class JustifyContentTests: XCTestCase, Sendable { flex.addItem(dView).size(20) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 160.0, width: 20.0, height: 20.0)) - XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 180.0, width: 20.0, height: 20.0)) - XCTAssertEqual(cView.frame, CGRect(x: 0.0, y: 200.0, width: 20.0, height: 20.0)) - XCTAssertEqual(dView.frame, CGRect(x: 0.0, y: 220.0, width: 20.0, height: 20.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 160.0, width: 20.0, height: 20.0)) + #expect(bView.frame == CGRect(x: 0.0, y: 180.0, width: 20.0, height: 20.0)) + #expect(cView.frame == CGRect(x: 0.0, y: 200.0, width: 20.0, height: 20.0)) + #expect(dView.frame == CGRect(x: 0.0, y: 220.0, width: 20.0, height: 20.0)) } - func test_justifyContent_adjust_view_position_spaceAround() { + @Test + func justifyContentAdjustViewPositionSpaceAround() { rootFlexContainer.flex.justifyContent(.spaceAround).define { flex in flex.addItem(aView).size(20) flex.addItem(bView).size(20) @@ -89,13 +93,14 @@ final class JustifyContentTests: XCTestCase, Sendable { flex.addItem(dView).size(20) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 40.0, width: 20.0, height: 20.0)) - XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 140.0, width: 20.0, height: 20.0)) - XCTAssertEqual(cView.frame, CGRect(x: 0.0, y: 240.0, width: 20.0, height: 20.0)) - XCTAssertEqual(dView.frame, CGRect(x: 0.0, y: 340.0, width: 20.0, height: 20.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 40.0, width: 20.0, height: 20.0)) + #expect(bView.frame == CGRect(x: 0.0, y: 140.0, width: 20.0, height: 20.0)) + #expect(cView.frame == CGRect(x: 0.0, y: 240.0, width: 20.0, height: 20.0)) + #expect(dView.frame == CGRect(x: 0.0, y: 340.0, width: 20.0, height: 20.0)) } - func test_justifyContent_adjust_view_position_spaceBetween() { + @Test + func justifyContentAdjustViewPositionSpaceBetween() { rootFlexContainer.flex.justifyContent(.spaceBetween).define { flex in flex.addItem(aView).size(20) flex.addItem(bView).size(20) @@ -104,13 +109,14 @@ final class JustifyContentTests: XCTestCase, Sendable { } rootFlexContainer.flex.layout() - XCTAssertTrue(aView.frame.beCloseTo(CGRect(x: 0.0, y: 0.0, width: 20.0, height: 20.0), within: 0.5)) - XCTAssertTrue(bView.frame.beCloseTo(CGRect(x: 0.0, y: 126.5, width: 20.0, height: 20.0), within: 0.5)) - XCTAssertTrue(cView.frame.beCloseTo(CGRect(x: 0.0, y: 253.0, width: 20.0, height: 20.0), within: 0.5)) - XCTAssertTrue(dView.frame.beCloseTo(CGRect(x: 0.0, y: 380.0, width: 20.0, height: 20.0), within: 0.5)) + #expect(aView.frame.beCloseTo(CGRect(x: 0.0, y: 0.0, width: 20.0, height: 20.0), within: 0.5)) + #expect(bView.frame.beCloseTo(CGRect(x: 0.0, y: 126.5, width: 20.0, height: 20.0), within: 0.5)) + #expect(cView.frame.beCloseTo(CGRect(x: 0.0, y: 253.0, width: 20.0, height: 20.0), within: 0.5)) + #expect(dView.frame.beCloseTo(CGRect(x: 0.0, y: 380.0, width: 20.0, height: 20.0), within: 0.5)) } - func test_justifyContent_adjust_view_position_spaceBetween_with_margin() { + @Test + func justifyContentAdjustViewPositionSpaceBetweenWithMargin() { rootFlexContainer.flex.justifyContent(.spaceBetween).define { flex in flex.addItem(aView).size(20).marginTop(10) flex.addItem(bView).size(20) @@ -118,10 +124,10 @@ final class JustifyContentTests: XCTestCase, Sendable { flex.addItem(dView).size(20).marginBottom(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 10.0, width: 20.0, height: 20.0)) - XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 130.0, width: 20.0, height: 20.0)) - XCTAssertEqual(cView.frame, CGRect(x: 0.0, y: 250.0, width: 20.0, height: 20.0)) - XCTAssertEqual(dView.frame, CGRect(x: 0.0, y: 370.0, width: 20.0, height: 20.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 10.0, width: 20.0, height: 20.0)) + #expect(bView.frame == CGRect(x: 0.0, y: 130.0, width: 20.0, height: 20.0)) + #expect(cView.frame == CGRect(x: 0.0, y: 250.0, width: 20.0, height: 20.0)) + #expect(dView.frame == CGRect(x: 0.0, y: 370.0, width: 20.0, height: 20.0)) } } diff --git a/Tests/FlexLayoutTests/WidthSizeContentTests.swift b/Tests/FlexLayoutTests/WidthSizeContentTests.swift index d247e87..76cb8d1 100644 --- a/Tests/FlexLayoutTests/WidthSizeContentTests.swift +++ b/Tests/FlexLayoutTests/WidthSizeContentTests.swift @@ -11,10 +11,11 @@ // POSSIBILITY OF SUCH DAMAGE. import FlexLayout -import XCTest +import Testing +import UIKit @MainActor -final class WidthSizeContentTests: XCTestCase, Sendable { +struct WidthSizeContentTests { var viewController: UIViewController! var rootFlexContainer: UIView! @@ -22,8 +23,7 @@ final class WidthSizeContentTests: XCTestCase, Sendable { var bView: UIView! var cView: UIView! - override func setUp() async throws { - try await super.setUp() + init() { viewController = UIViewController() @@ -36,24 +36,27 @@ final class WidthSizeContentTests: XCTestCase, Sendable { cView = UIView() } - func test_basis_adjust_aView_size_and_position() { + @Test + func basisAdjustAViewSizeAndPosition() { rootFlexContainer.flex.define { flex in flex.addItem(aView).width(100).height(200) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 100.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 100.0, height: 200.0)) } - func test_basis_adjust_aView_size_and_position_with_aspectRatio() { + @Test + func basisAdjustAViewSizeAndPositionWithAspectRatio() { rootFlexContainer.flex.define { flex in flex.addItem(aView).width(200).aspectRatio(2) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 200.0, height: 100.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 200.0, height: 100.0)) } - func test_basis_adjust_aView_size_and_position_with_aspectRatio_reset() { + @Test + func basisAdjustAViewSizeAndPositionWithAspectRatioReset() { rootFlexContainer.flex.define { flex in flex.addItem(aView).width(200).aspectRatio(2) } @@ -61,19 +64,21 @@ final class WidthSizeContentTests: XCTestCase, Sendable { // Later reset the aspectRatio aView.flex.aspectRatio(nil) rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 200.0, height: 0.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 200.0, height: 0.0)) } - func test_basis_adjust_aView_size_and_position_with_width_height() { + @Test + func basisAdjustAViewSizeAndPositionWithWidthHeight() { rootFlexContainer.flex.define { flex in flex.addItem(aView).width(200).minWidth(100).height(200).minHeight(100) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 200.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 200.0, height: 200.0)) } - func test_basis_adjust_aView_size_and_position_with_width_height_reset() { + @Test + func basisAdjustAViewSizeAndPositionWithWidthHeightReset() { rootFlexContainer.flex.define { flex in flex.addItem(aView).width(200).minWidth(100).height(200).minHeight(100) } @@ -82,19 +87,21 @@ final class WidthSizeContentTests: XCTestCase, Sendable { aView.flex.width(nil) aView.flex.height(nil) rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 100.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 100.0)) } - func test_basis_adjust_aView_size_and_position_with_minWidth() { + @Test + func basisAdjustAViewSizeAndPositionWithMinWidth() { rootFlexContainer.flex.define { flex in flex.addItem(aView).width(200).minWidth(300).height(200) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 300.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 300.0, height: 200.0)) } - func test_basis_adjust_aView_size_and_position_with_minWidth_reset() { + @Test + func basisAdjustAViewSizeAndPositionWithMinWidthReset() { rootFlexContainer.flex.define { flex in flex.addItem(aView).width(200).maxWidth(300).height(200) } @@ -102,19 +109,21 @@ final class WidthSizeContentTests: XCTestCase, Sendable { // Later reset the minWidth aView.flex.minWidth(nil) rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 200.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 200.0, height: 200.0)) } - func test_basis_adjust_aView_size_and_position_with_maxWidth() { + @Test + func basisAdjustAViewSizeAndPositionWithMaxWidth() { rootFlexContainer.flex.define { flex in flex.addItem(aView).maxWidth(300).height(200) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 300.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 300.0, height: 200.0)) } - func test_basis_adjust_aView_size_and_position_with_maxWidth_reset() { + @Test + func basisAdjustAViewSizeAndPositionWithMaxWidthReset() { rootFlexContainer.flex.define { flex in flex.addItem(aView).maxWidth(300).height(200) } @@ -122,19 +131,21 @@ final class WidthSizeContentTests: XCTestCase, Sendable { // Later reset the width and the height aView.flex.maxWidth(nil) rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 200.0)) } - func test_basis_adjust_aView_size_and_position_with_minHeight() { + @Test + func basisAdjustAViewSizeAndPositionWithMinHeight() { rootFlexContainer.flex.define { flex in flex.addItem(aView).height(200).minHeight(300) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 300.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 300.0)) } - func test_basis_adjust_aView_size_and_position_with_minHeight_reset() { + @Test + func basisAdjustAViewSizeAndPositionWithMinHeightReset() { rootFlexContainer.flex.define { flex in flex.addItem(aView).height(200).minHeight(300) } @@ -142,19 +153,21 @@ final class WidthSizeContentTests: XCTestCase, Sendable { // Later reset the minHeight aView.flex.minHeight(nil) rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 200.0)) } - func test_basis_adjust_aView_size_and_position_with_maxHeight() { + @Test + func basisAdjustAViewSizeAndPositionWithMaxHeight() { rootFlexContainer.flex.define { flex in flex.addItem(aView).height(200).maxHeight(100) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 100.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 100.0)) } - func test_basis_adjust_aView_size_and_position_with_maxHeight_reset() { + @Test + func basisAdjustAViewSizeAndPositionWithMaxHeightReset() { rootFlexContainer.flex.define { flex in flex.addItem(aView).height(200).maxHeight(100) } @@ -162,10 +175,11 @@ final class WidthSizeContentTests: XCTestCase, Sendable { // Later reset the maxHeight aView.flex.maxHeight(nil) rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 200.0)) } - func test_row_gap() { + @Test + func rowGap() { rootFlexContainer.flex.direction(.row).define { flex in flex.addItem(aView).height(100).width(100) flex.addItem(bView).height(100).width(100) @@ -175,10 +189,11 @@ final class WidthSizeContentTests: XCTestCase, Sendable { } rootFlexContainer.flex.layout() - XCTAssertEqual(bView.frame, CGRect(x: 150.0, y: 0.0, width: 100.0, height: 100.0)) + #expect(bView.frame == CGRect(x: 150.0, y: 0.0, width: 100.0, height: 100.0)) } - func test_column_gap() { + @Test + func columnGap() { rootFlexContainer.flex.direction(.column).define { flex in flex.addItem(aView).height(100).width(100) flex.addItem(bView).height(100).width(100) @@ -188,10 +203,11 @@ final class WidthSizeContentTests: XCTestCase, Sendable { } rootFlexContainer.flex.layout() - XCTAssertEqual(bView.frame, CGRect(x: 0.0, y: 150.0, width: 100.0, height: 100.0)) + #expect(bView.frame == CGRect(x: 0.0, y: 150.0, width: 100.0, height: 100.0)) } - func test_gap() { + @Test + func gap() { rootFlexContainer.flex.direction(.column).define { flex in flex.addItem().direction(.row).define { flex in flex.addItem(aView).height(100).width(100) @@ -206,7 +222,7 @@ final class WidthSizeContentTests: XCTestCase, Sendable { rootFlexContainer.flex.layout() - XCTAssertEqual(bView.frame, CGRect(x: 150.0, y: 0.0, width: 100.0, height: 100.0)) - XCTAssertEqual(cView.frame, CGRect(x: 0.0, y: 150.0, width: 100.0, height: 100.0)) + #expect(bView.frame == CGRect(x: 150.0, y: 0.0, width: 100.0, height: 100.0)) + #expect(cView.frame == CGRect(x: 0.0, y: 150.0, width: 100.0, height: 100.0)) } } From 8bc4699cdf1e37739158b3ad82f41d17abe2c274 Mon Sep 17 00:00:00 2001 From: heoblitz <25315898+heoblitz@users.noreply.github.com> Date: Fri, 6 Nov 2026 23:26:04 +0900 Subject: [PATCH 2/2] Migrate spacing tests to Swift Testing --- Tests/FlexLayoutTests/InsetTests.swift | 88 ++++++++++-------- Tests/FlexLayoutTests/MarginTests.swift | 63 +++++++------ Tests/FlexLayoutTests/PaddingTests.swift | 108 ++++++++++++++--------- 3 files changed, 153 insertions(+), 106 deletions(-) diff --git a/Tests/FlexLayoutTests/InsetTests.swift b/Tests/FlexLayoutTests/InsetTests.swift index a7bfb54..837a8f9 100644 --- a/Tests/FlexLayoutTests/InsetTests.swift +++ b/Tests/FlexLayoutTests/InsetTests.swift @@ -11,17 +11,17 @@ // POSSIBILITY OF SUCH DAMAGE. import FlexLayout -import XCTest +import Testing +import UIKit @MainActor -final class InsetTests: XCTestCase, Sendable { +struct InsetTests { var viewController: UIViewController! var rootFlexContainer: UIView! var aView: UIView! - override func setUp() async throws { - try await super.setUp() + init() { viewController = UIViewController() @@ -32,64 +32,72 @@ final class InsetTests: XCTestCase, Sendable { aView = UIView() } - func test_adjust_the_aView_size_and_relative_position_with_left() { + @Test + func adjustTheAViewSizeAndRelativePositionWithLeft() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.relative).grow(1).left(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_relative_position_with_top() { + @Test + func adjustTheAViewSizeAndRelativePositionWithTop() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.relative).grow(1).top(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 10.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 10.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_relative_position_with_right() { + @Test + func adjustTheAViewSizeAndRelativePositionWithRight() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.relative).grow(1).right(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: -10.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: -10.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_relative_position_with_bottom() { + @Test + func adjustTheAViewSizeAndRelativePositionWithBottom() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.relative).grow(1).bottom(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: -10.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: -10.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_relative_position_with_horizontally() { + @Test + func adjustTheAViewSizeAndRelativePositionWithHorizontally() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.relative).grow(1).horizontally(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_relative_position_with_vertically() { + @Test + func adjustTheAViewSizeAndRelativePositionWithVertically() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.relative).grow(1).vertically(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 10.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 10.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_absolute_position_with_left_right() { + @Test + func adjustTheAViewSizeAbsolutePositionWithLeftRight() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.absolute).left(10).right(10).width(300).height(200) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 300.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 0.0, width: 300.0, height: 200.0)) } - func test_adjust_the_aView_size_absolute_position_with_right_and_reset_left_later() { + @Test + func adjustTheAViewSizeAbsolutePositionWithRightAndResetLeftLater() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.absolute).left(10).right(10).width(300).height(200) } @@ -97,72 +105,80 @@ final class InsetTests: XCTestCase, Sendable { // Later reset the aspectRatio aView.flex.left(0) rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 300.0, height: 200.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 300.0, height: 200.0)) } - func test_adjust_the_aView_size_absolute_position_with_horizontally_vertically() { + @Test + func adjustTheAViewSizeAbsolutePositionWithHorizontallyVertically() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.absolute).horizontally(15).vertically(20) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 15.0, y: 20.0, width: 370.0, height: 360.0)) + #expect(aView.frame == CGRect(x: 15.0, y: 20.0, width: 370.0, height: 360.0)) } - func test_adjust_the_aView_size_absolute_position_with_all() { + @Test + func adjustTheAViewSizeAbsolutePositionWithAll() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.absolute).all(45) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 45.0, y: 45.0, width: 310.0, height: 310.0)) + #expect(aView.frame == CGRect(x: 45.0, y: 45.0, width: 310.0, height: 310.0)) } - func test_adjust_the_aView_size_and_relative_static_with_left() { + @Test + func adjustTheAViewSizeAndRelativeStaticWithLeft() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.static).grow(1).left(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_static_position_with_top() { + @Test + func adjustTheAViewSizeAndStaticPositionWithTop() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.static).grow(1).top(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_static_position_with_right() { + @Test + func adjustTheAViewSizeAndStaticPositionWithRight() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.static).grow(1).right(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_static_position_with_bottom() { + @Test + func adjustTheAViewSizeAndStaticPositionWithBottom() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.static).grow(1).bottom(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_static_position_with_horizontally() { + @Test + func adjustTheAViewSizeAndStaticPositionWithHorizontally() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.static).grow(1).horizontally(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_static_position_with_vertically() { + @Test + func adjustTheAViewSizeAndStaticPositionWithVertically() { rootFlexContainer.flex.define { flex in flex.addItem(aView).position(.static).grow(1).vertically(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) } } diff --git a/Tests/FlexLayoutTests/MarginTests.swift b/Tests/FlexLayoutTests/MarginTests.swift index 3f0fc72..30d0c4c 100644 --- a/Tests/FlexLayoutTests/MarginTests.swift +++ b/Tests/FlexLayoutTests/MarginTests.swift @@ -11,17 +11,17 @@ // POSSIBILITY OF SUCH DAMAGE. import FlexLayout -import XCTest +import Testing +import UIKit @MainActor -final class MarginTests: XCTestCase, Sendable { +struct MarginTests { var viewController: UIViewController! var rootFlexContainer: UIView! var aView: UIView! - override func setUp() async throws { - try await super.setUp() + init() { viewController = UIViewController() @@ -32,90 +32,101 @@ final class MarginTests: XCTestCase, Sendable { aView = UIView() } - func test_adjust_the_rootFlexContainer_size_and_position() { + @Test + func adjustTheRootFlexContainerSizeAndPosition() { rootFlexContainer.flex.define { _ in } rootFlexContainer.flex.layout() - XCTAssertEqual(rootFlexContainer.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(rootFlexContainer.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position() { + @Test + func adjustTheAViewSizeAndPosition() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_marginLeft() { + @Test + func adjustTheAViewSizeAndPositionWithMarginLeft() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1).marginLeft(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 390.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 0.0, width: 390.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_marginTop() { + @Test + func adjustTheAViewSizeAndPositionWithMarginTop() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1).marginTop(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 10.0, width: 400.0, height: 390.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 10.0, width: 400.0, height: 390.0)) } - func test_adjust_the_aView_size_and_position_with_marginBottom() { + @Test + func adjustTheAViewSizeAndPositionWithMarginBottom() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1).marginBottom(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 390.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 390.0)) } - func test_adjust_the_aView_size_and_position_with_marginStart() { + @Test + func adjustTheAViewSizeAndPositionWithMarginStart() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1).marginStart(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 390.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 0.0, width: 390.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_marginEnd() { + @Test + func adjustTheAViewSizeAndPositionWithMarginEnd() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1).marginEnd(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 390.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 390.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_margin() { + @Test + func adjustTheAViewSizeAndPositionWithMargin() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1).margin(10, 20, 30, 40) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 20.0, y: 10.0, width: 340.0, height: 360.0)) + #expect(aView.frame == CGRect(x: 20.0, y: 10.0, width: 340.0, height: 360.0)) } - func test_adjust_the_aView_size_and_position_with_margin_all() { + @Test + func adjustTheAViewSizeAndPositionWithMarginAll() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1).margin(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 10.0, width: 380.0, height: 380.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 10.0, width: 380.0, height: 380.0)) } - func test_adjust_the_aView_size_and_position_with_marginVertical() { + @Test + func adjustTheAViewSizeAndPositionWithMarginVertical() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1).marginVertical(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 10.0, width: 400.0, height: 380.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 10.0, width: 400.0, height: 380.0)) } - func test_adjust_the_aView_size_and_position_with_marginHorizontal() { + @Test + func adjustTheAViewSizeAndPositionWithMarginHorizontal() { rootFlexContainer.flex.define { flex in flex.addItem(aView).grow(1).marginHorizontal(10) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 380.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 0.0, width: 380.0, height: 400.0)) } } diff --git a/Tests/FlexLayoutTests/PaddingTests.swift b/Tests/FlexLayoutTests/PaddingTests.swift index e43f775..5c96a09 100644 --- a/Tests/FlexLayoutTests/PaddingTests.swift +++ b/Tests/FlexLayoutTests/PaddingTests.swift @@ -11,17 +11,17 @@ // POSSIBILITY OF SUCH DAMAGE. import FlexLayout -import XCTest +import Testing +import UIKit @MainActor -final class PaddingTests: XCTestCase, Sendable { +struct PaddingTests { var viewController: UIViewController! var rootFlexContainer: UIView! var aView: UIView! - override func setUp() async throws { - try await super.setUp() + init() { viewController = UIViewController() @@ -32,165 +32,185 @@ final class PaddingTests: XCTestCase, Sendable { aView = UIView() } - func test_adjust_the_aView_size_and_position_with_paddingTop() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingTop() { rootFlexContainer.flex.paddingTop(10).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 10.0, width: 400.0, height: 390.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 10.0, width: 400.0, height: 390.0)) } - func test_adjust_the_aView_size_and_position_with_paddingTop_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingTopPercent() { rootFlexContainer.flex.paddingTop(10%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 40.0, width: 400.0, height: 360.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 40.0, width: 400.0, height: 360.0)) } - func test_adjust_the_aView_size_and_position_with_paddingLeft() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingLeft() { rootFlexContainer.flex.paddingLeft(10).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 390.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 0.0, width: 390.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_paddingLeft_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingLeftPercent() { rootFlexContainer.flex.paddingLeft(10%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 40.0, y: 0.0, width: 360.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 40.0, y: 0.0, width: 360.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_paddingBottom() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingBottom() { rootFlexContainer.flex.paddingBottom(10).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 390.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 390.0)) } - func test_adjust_the_aView_size_and_position_with_paddingBottom_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingBottomPercent() { rootFlexContainer.flex.paddingBottom(10%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 400.0, height: 360.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 400.0, height: 360.0)) } - func test_adjust_the_aView_size_and_position_with_paddingRight() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingRight() { rootFlexContainer.flex.paddingRight(10).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 390.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 390.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_paddingRight_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingRightPercent() { rootFlexContainer.flex.paddingRight(10%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 360.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 360.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_padding_all() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingAll() { rootFlexContainer.flex.padding(10).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 10.0, width: 380.0, height: 380.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 10.0, width: 380.0, height: 380.0)) } - func test_adjust_the_aView_size_and_position_with_padding_all_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingAllPercent() { rootFlexContainer.flex.padding(10%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 40.0, y: 40.0, width: 320.0, height: 320.0)) + #expect(aView.frame == CGRect(x: 40.0, y: 40.0, width: 320.0, height: 320.0)) } - func test_adjust_the_aView_size_and_position_with_padding() { + @Test + func adjustTheAViewSizeAndPositionWithPadding() { rootFlexContainer.flex.padding(10, 20, 30, 40).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 20.0, y: 10.0, width: 340.0, height: 360.0)) + #expect(aView.frame == CGRect(x: 20.0, y: 10.0, width: 340.0, height: 360.0)) } - func test_adjust_the_aView_size_and_position_with_padding_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingPercent() { rootFlexContainer.flex.padding(10%, 20%, 30%, 40%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 80.0, y: 40.0, width: 160.0, height: 240.0)) + #expect(aView.frame == CGRect(x: 80.0, y: 40.0, width: 160.0, height: 240.0)) } - func test_adjust_the_aView_size_and_position_with_paddingStart() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingStart() { rootFlexContainer.flex.paddingStart(10).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 390.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 0.0, width: 390.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_paddingStart_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingStartPercent() { rootFlexContainer.flex.paddingStart(10%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 40.0, y: 0.0, width: 360.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 40.0, y: 0.0, width: 360.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_paddingEnd() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingEnd() { rootFlexContainer.flex.paddingEnd(10).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 390.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 390.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_paddingEnd_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingEndPercent() { rootFlexContainer.flex.paddingEnd(10%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 0.0, width: 360.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 0.0, width: 360.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_paddingVertical() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingVertical() { rootFlexContainer.flex.paddingVertical(10).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 10.0, width: 400.0, height: 380.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 10.0, width: 400.0, height: 380.0)) } - func test_adjust_the_aView_size_and_position_with_paddingVertical_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingVerticalPercent() { rootFlexContainer.flex.paddingVertical(10%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 40.0, width: 400.0, height: 320.0)) + #expect(aView.frame == CGRect(x: 0.0, y: 40.0, width: 400.0, height: 320.0)) } - func test_adjust_the_aView_size_and_position_with_paddingHorizontal() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingHorizontal() { rootFlexContainer.flex.paddingHorizontal(10).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 380.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 10.0, y: 0.0, width: 380.0, height: 400.0)) } - func test_adjust_the_aView_size_and_position_with_paddingHorizontal_percent() { + @Test + func adjustTheAViewSizeAndPositionWithPaddingHorizontalPercent() { rootFlexContainer.flex.paddingHorizontal(10%).define { flex in flex.addItem(aView).grow(1) } rootFlexContainer.flex.layout() - XCTAssertEqual(aView.frame, CGRect(x: 40.0, y: 0.0, width: 320.0, height: 400.0)) + #expect(aView.frame == CGRect(x: 40.0, y: 0.0, width: 320.0, height: 400.0)) } }