From 3a08734552978666759501827c429457e9de34b4 Mon Sep 17 00:00:00 2001 From: Darius Jankauskas Date: Wed, 14 Sep 2016 13:05:36 +0100 Subject: [PATCH 1/4] auto conversion to swift 3 --- CGRectExtensions.xcodeproj/project.pbxproj | 16 +- CGRectExtensions/CGRectExtensions.swift | 220 ++++++++++----------- CGRectExtensionsTests/OperatorTests.swift | 14 +- CGRectExtensionsTests/SizesTests.swift | 40 ++-- 4 files changed, 151 insertions(+), 139 deletions(-) diff --git a/CGRectExtensions.xcodeproj/project.pbxproj b/CGRectExtensions.xcodeproj/project.pbxproj index 1be55fb..8c7ccb2 100644 --- a/CGRectExtensions.xcodeproj/project.pbxproj +++ b/CGRectExtensions.xcodeproj/project.pbxproj @@ -7,8 +7,8 @@ objects = { /* Begin PBXBuildFile section */ - 24091C0F1BA1EFCF00980A3E /* DescriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24091C0E1BA1EFCF00980A3E /* DescriptionTests.swift */; settings = {ASSET_TAGS = (); }; }; - 24091C101BA1F02500980A3E /* DescriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24091C0E1BA1EFCF00980A3E /* DescriptionTests.swift */; settings = {ASSET_TAGS = (); }; }; + 24091C0F1BA1EFCF00980A3E /* DescriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24091C0E1BA1EFCF00980A3E /* DescriptionTests.swift */; }; + 24091C101BA1F02500980A3E /* DescriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24091C0E1BA1EFCF00980A3E /* DescriptionTests.swift */; }; 242C641319D5C78A00D51D9F /* InsetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 242C641219D5C78A00D51D9F /* InsetTests.swift */; }; 242C641519D5CCAD00D51D9F /* ExtendTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 242C641419D5CCAD00D51D9F /* ExtendTests.swift */; }; 242C642019D5CF5100D51D9F /* CGRectExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 242C641F19D5CF5100D51D9F /* CGRectExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -291,15 +291,19 @@ TargetAttributes = { 242C641A19D5CF5000D51D9F = { CreatedOnToolsVersion = 6.1; + LastSwiftMigration = 0800; }; 242C642419D5CF5100D51D9F = { CreatedOnToolsVersion = 6.1; + LastSwiftMigration = 0800; }; 247BBDF719D4A89F00A782E2 = { CreatedOnToolsVersion = 6.1; + LastSwiftMigration = 0800; }; 247BBE0219D4A89F00A782E2 = { CreatedOnToolsVersion = 6.1; + LastSwiftMigration = 0800; }; }; }; @@ -439,6 +443,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -459,6 +464,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -482,6 +488,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "de.nschum.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -499,6 +506,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "de.nschum.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_VERSION = 3.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -602,6 +610,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "de.nschum.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = CGRectExtensions; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -620,6 +629,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "de.nschum.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = CGRectExtensions; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -639,6 +649,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "de.nschum.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -654,6 +665,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "de.nschum.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/CGRectExtensions/CGRectExtensions.swift b/CGRectExtensions/CGRectExtensions.swift index e6176c8..40679bb 100644 --- a/CGRectExtensions/CGRectExtensions.swift +++ b/CGRectExtensions/CGRectExtensions.swift @@ -30,11 +30,11 @@ extension CGPoint { } /// Returns a copy with the x value changed. - public func with(x x: CGFloat) -> CGPoint { + public func with(x: CGFloat) -> CGPoint { return CGPoint(x: x, y: y) } /// Returns a copy with the y value changed. - public func with(y y: CGFloat) -> CGPoint { + public func with(y: CGFloat) -> CGPoint { return CGPoint(x: x, y: y) } } @@ -50,11 +50,11 @@ extension CGSize { } /// Returns a copy with the width value changed. - public func with(width width: CGFloat) -> CGSize { + public func with(width: CGFloat) -> CGSize { return CGSize(width: width, height: height) } /// Returns a copy with the height value changed. - public func with(height height: CGFloat) -> CGSize { + public func with(height: CGFloat) -> CGSize { return CGSize(width: width, height: height) } } @@ -189,107 +189,107 @@ extension CGRect { // MARK: with /// Returns a copy with the origin value changed. - public func with(origin origin: CGPoint) -> CGRect { + public func with(origin: CGPoint) -> CGRect { return CGRect(origin: origin, size: size) } /// Returns a copy with the x and y values changed. - public func with(x x: CGFloat, y: CGFloat) -> CGRect { + public func with(x: CGFloat, y: CGFloat) -> CGRect { return with(origin: CGPoint(x: x, y: y)) } /// Returns a copy with the x value changed. - public func with(x x: CGFloat) -> CGRect { + public func with(x: CGFloat) -> CGRect { return with(x: x, y: y) } /// Returns a copy with the y value changed. - public func with(y y: CGFloat) -> CGRect { + public func with(y: CGFloat) -> CGRect { return with(x: x, y: y) } /// Returns a copy with the size value changed. - public func with(size size: CGSize) -> CGRect { + public func with(size: CGSize) -> CGRect { return CGRect(origin: origin, size: size) } /// Returns a copy with the width and height values changed. - public func with(width width: CGFloat, height: CGFloat) -> CGRect { + public func with(width: CGFloat, height: CGFloat) -> CGRect { return with(size: CGSize(width: width, height: height)) } /// Returns a copy with the width value changed. - public func with(width width: CGFloat) -> CGRect { + public func with(width: CGFloat) -> CGRect { return with(width: width, height: height) } /// Returns a copy with the height value changed. - public func with(height height: CGFloat) -> CGRect { + public func with(height: CGFloat) -> CGRect { return with(width: width, height: height) } /// Returns a copy with the x and width values changed. - public func with(x x: CGFloat, width: CGFloat) -> CGRect { + public func with(x: CGFloat, width: CGFloat) -> CGRect { return CGRect(origin: CGPoint(x: x, y: y), size: CGSize(width: width, height: height)) } /// Returns a copy with the y and height values changed. - public func with(y y: CGFloat, height: CGFloat) -> CGRect { + public func with(y: CGFloat, height: CGFloat) -> CGRect { return CGRect(origin: CGPoint(x: x, y: y), size: CGSize(width: width, height: height)) } // MARK: offset /// Returns a copy with the x and y values offset. - public func offsetBy(dx: CGFloat, _ dy: CGFloat) -> CGRect { + public func offsetBy(_ dx: CGFloat, _ dy: CGFloat) -> CGRect { return with(x: x + dx, y: y + dy) } /// Returns a copy with the x value values offset. - public func offsetBy(dx dx: CGFloat) -> CGRect { + public func offsetBy(dx: CGFloat) -> CGRect { return with(x: x + dx) } /// Returns a copy with the y value values offset. - public func offsetBy(dy dy: CGFloat) -> CGRect { + public func offsetBy(dy: CGFloat) -> CGRect { return with(y: y + dy) } /// Returns a copy with the x and y values offset. - public func offsetBy(by: CGSize) -> CGRect { + public func offsetBy(_ by: CGSize) -> CGRect { return with(x: x + by.width, y: y + by.height) } /// Modifies the x and y values by offsetting. - public mutating func offsetInPlace(dx: CGFloat, _ dy: CGFloat) { - offsetInPlace(dx: dx, dy: dy) + public mutating func offsetInPlace(_ dx: CGFloat, _ dy: CGFloat) { + offsetInPlace(dx, dy) } /// Modifies the x value values by offsetting. - public mutating func offsetInPlace(dx dx: CGFloat = 0) { + public mutating func offsetInPlace(dx: CGFloat = 0) { x += dx } /// Modifies the y value values by offsetting. - public mutating func offsetInPlace(dy dy: CGFloat = 0) { + public mutating func offsetInPlace(dy: CGFloat = 0) { y += dy } /// Modifies the x and y values by offsetting. - public mutating func offsetInPlace(by: CGSize) { - offsetInPlace(dx: by.width, dy: by.height) + public mutating func offsetInPlace(_ by: CGSize) { + offsetInPlace(by.width, by.height) } // MARK: inset /// Returns a copy inset on all edges by the same value. - public func insetBy(by: CGFloat) -> CGRect { + public func insetBy(_ by: CGFloat) -> CGRect { return insetBy(dx: by, dy: by) } /// Returns a copy inset on the left and right edges. - public func insetBy(dx dx: CGFloat) -> CGRect { + public func insetBy(dx: CGFloat) -> CGRect { return with(x: x + dx, width: width - dx * 2) } /// Returns a copy inset on the top and bottom edges. - public func insetBy(dy dy: CGFloat) -> CGRect { + public func insetBy(dy: CGFloat) -> CGRect { return with(y: y + dy, height: height - dy * 2) } /// Returns a copy inset on all edges by different values. - public func insetBy(minX minX: CGFloat = 0, minY: CGFloat = 0, maxX: CGFloat = 0, maxY: CGFloat = 0) -> CGRect { + public func insetBy(minX: CGFloat = 0, minY: CGFloat = 0, maxX: CGFloat = 0, maxY: CGFloat = 0) -> CGRect { return CGRect(x: x + minX, y: y + minY, width: width - minX - maxX, height: height - minY - maxY) } /// Returns a copy inset on all edges by different values. - public func insetBy(top top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> CGRect { + public func insetBy(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> CGRect { #if os(iOS) return CGRect(x: x + left, y: y + top, width: width - right - left, height: height - top - bottom) #else @@ -298,190 +298,190 @@ extension CGRect { } /// Returns a copy inset on the top and left edges. - public func insetBy(topLeft topLeft: CGSize) -> CGRect { + public func insetBy(topLeft: CGSize) -> CGRect { return insetBy(top: topLeft.height, left: topLeft.width) } /// Returns a copy inset on the top and right edges. - public func insetBy(topRight topRight: CGSize) -> CGRect { + public func insetBy(topRight: CGSize) -> CGRect { return insetBy(top: topRight.height, right: topRight.width) } /// Returns a copy inset on the bottom and left edges. - public func insetBy(bottomLeft bottomLeft: CGSize) -> CGRect { + public func insetBy(bottomLeft: CGSize) -> CGRect { return insetBy(bottom: bottomLeft.height, left: bottomLeft.width) } /// Returns a copy inset on the bottom and right edges. - public func insetBy(bottomRight bottomRight: CGSize) -> CGRect { + public func insetBy(bottomRight: CGSize) -> CGRect { return insetBy(bottom: bottomRight.height, right: bottomRight.width) } /// Modifies all values by insetting all edges by the same value. - public mutating func insetInPlace(by: CGFloat) { + public mutating func insetInPlace(_ by: CGFloat) { insetInPlace(dx: by, dy: by) } /// Modifies all values by insetting on the left and right edges. - public mutating func insetInPlace(dx dx: CGFloat) { + public mutating func insetInPlace(dx: CGFloat) { insetInPlace(dx: dx, dy: 0) } /// Modifies all values by insetting on the top and bottom edges. - public mutating func insetInPlace(dy dy: CGFloat) { + public mutating func insetInPlace(dy: CGFloat) { insetInPlace(dx: 0, dy: dy) } /// Modifies all values by insetting all edges by different value. - public mutating func insetInPlace(minX minX: CGFloat = 0, minY: CGFloat = 0, maxX: CGFloat = 0, maxY: CGFloat = 0) { + public mutating func insetInPlace(minX: CGFloat = 0, minY: CGFloat = 0, maxX: CGFloat = 0, maxY: CGFloat = 0) { self = insetBy(minX: minX, minY: minY, maxX: maxX, maxY: maxY) } /// Modifies all values by insetting all edges by different value. - public mutating func insetInPlace(top top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) { + public mutating func insetInPlace(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) { self = insetBy(top: top, left: left, bottom: bottom, right: right) } /// Modifies all values by insetting the top and left edges. - public mutating func insetInPlace(topLeft topLeft: CGSize) { + public mutating func insetInPlace(topLeft: CGSize) { self = insetBy(topLeft: topLeft) } /// Modifies all values by insetting the top and right edges. - public mutating func insetInPlace(topRight topRight: CGSize) { + public mutating func insetInPlace(topRight: CGSize) { self = insetBy(topRight: topRight) } /// Modifies all values by insetting the bottom and left edges. - public mutating func insetInPlace(bottomLeft bottomLeft: CGSize) { + public mutating func insetInPlace(bottomLeft: CGSize) { self = insetBy(bottomLeft: bottomLeft) } /// Modifies all values by insetting the bottom and right edges. - public mutating func insetInPlace(bottomRight bottomRight: CGSize) { + public mutating func insetInPlace(bottomRight: CGSize) { self = insetBy(bottomRight: bottomRight) } // MARK: extending /// Returns a copy extended on all edges by different values. - public func extendBy(dx dx: CGFloat, dy: CGFloat = 0) -> CGRect { + public func extendBy(dx: CGFloat, dy: CGFloat = 0) -> CGRect { return insetBy(dx: -dx, dy: -dy) } /// Returns a copy extended on the top and bottom edges. - public func extendBy(dy dy: CGFloat) -> CGRect { + public func extendBy(dy: CGFloat) -> CGRect { return insetBy(dy: -dy) } /// Returns a copy extended on all edges by the same value. - public func extendBy(by: CGFloat) -> CGRect { + public func extendBy(_ by: CGFloat) -> CGRect { return insetBy(dx: -by, dy: -by) } /// Returns a copy extended on all edges by different values. - public func extendBy(minX minX: CGFloat = 0, minY: CGFloat = 0, maxX: CGFloat = 0, maxY: CGFloat = 0) -> CGRect { + public func extendBy(minX: CGFloat = 0, minY: CGFloat = 0, maxX: CGFloat = 0, maxY: CGFloat = 0) -> CGRect { return insetBy(minX: -minX, minY: -minY, maxX: -maxX, maxY: -maxY) } /// Returns a copy extended on all edges by different values. - public func extendBy(top top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> CGRect { + public func extendBy(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) -> CGRect { return insetBy(top: -top, left: -left, bottom: -bottom, right: -right) } /// Modifies all values by extending the top and left edges. - public func extendBy(topLeft topLeft: CGSize) -> CGRect { + public func extendBy(topLeft: CGSize) -> CGRect { return extendBy(top: topLeft.height, left: topLeft.width) } /// Modifies all values by extending the top and right edges. - public func extendBy(topRight topRight: CGSize) -> CGRect { + public func extendBy(topRight: CGSize) -> CGRect { return insetBy(top: -topRight.height, right: -topRight.width) } /// Modifies all values by extending the bottom and left edges. - public func extendBy(bottomLeft bottomLeft: CGSize) -> CGRect { + public func extendBy(bottomLeft: CGSize) -> CGRect { return insetBy(bottom: -bottomLeft.height, left: -bottomLeft.width) } /// Modifies all values by extending the bottom and right edges. - public func extendBy(bottomRight bottomRight: CGSize) -> CGRect { + public func extendBy(bottomRight: CGSize) -> CGRect { return insetBy(bottom: -bottomRight.height, right: -bottomRight.width) } /// Modifies all values by extending all edges by different values. - public mutating func extendInPlace(dx dx: CGFloat, dy: CGFloat = 0) { + public mutating func extendInPlace(dx: CGFloat, dy: CGFloat = 0) { self = insetBy(dx: -dx, dy: -dy) } /// Modifies all values by extending the top and bottom edges. - public mutating func extendInPlace(dy dy: CGFloat) { + public mutating func extendInPlace(dy: CGFloat) { self = insetBy(dy: -dy) } /// Modifies all values by extending all edges by the same value. - public mutating func extendInPlace(by: CGFloat) { + public mutating func extendInPlace(_ by: CGFloat) { self = insetBy(dx: -by, dy: -by) } /// Modifies all values by extending all edges by different values. - public mutating func extendInPlace(minX minX: CGFloat = 0, minY: CGFloat = 0, maxX: CGFloat = 0, maxY: CGFloat = 0) { + public mutating func extendInPlace(minX: CGFloat = 0, minY: CGFloat = 0, maxX: CGFloat = 0, maxY: CGFloat = 0) { self = insetBy(minX: -minX, minY: -minY, maxX: -maxX, maxY: -maxY) } /// Modifies all values by extending all edges by different values. - public mutating func extendInPlace(top top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) { + public mutating func extendInPlace(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) { self = insetBy(top: -top, left: -left, bottom: -bottom, right: -right) } /// Modifies all values by extending the top and left edges. - public mutating func extendInPlace(topLeft topLeft: CGSize) { + public mutating func extendInPlace(topLeft: CGSize) { self = extendBy(top: topLeft.height, left: topLeft.width) } /// Modifies all values by extending the top and right edges. - public mutating func extendInPlace(topRight topRight: CGSize) { + public mutating func extendInPlace(topRight: CGSize) { self = insetBy(top: -topRight.height, right: -topRight.width) } /// Modifies all values by extending the bottom and left edges. - public mutating func extendInPlace(bottomLeft bottomLeft: CGSize) { + public mutating func extendInPlace(bottomLeft: CGSize) { self = insetBy(bottom: -bottomLeft.height, left: -bottomLeft.width) } /// Modifies all values by extending the bottom and right edges. - public mutating func extendInPlace(bottomRight bottomRight: CGSize) { + public mutating func extendInPlace(bottomRight: CGSize) { self = insetBy(bottom: -bottomRight.height, right: -bottomRight.width) } // MARK: sizes /// Returns a rect of the specified size centered in this rect. - public func center(size: CGSize) -> CGRect { + public func center(_ size: CGSize) -> CGRect { let dx = width - size.width let dy = height - size.height return CGRect(x: x + dx * 0.5, y: y + dy * 0.5, width: size.width, height: size.height) } /// Returns a rect of the specified size centered in this rect touching the specified edge. - public func center(size: CGSize, alignTo edge: CGRectEdge) -> CGRect { + public func center(_ size: CGSize, alignTo edge: CGRectEdge) -> CGRect { return CGRect(origin: alignedOrigin(size, edge: edge), size: size) } - private func alignedOrigin(size: CGSize, edge: CGRectEdge) -> CGPoint { + fileprivate func alignedOrigin(_ size: CGSize, edge: CGRectEdge) -> CGPoint { let dx = width - size.width let dy = height - size.height switch edge { - case .MinXEdge: + case .minXEdge: return CGPoint(x: x, y: y + dy * 0.5) - case .MinYEdge: + case .minYEdge: return CGPoint(x: x + dx * 0.5, y: y) - case .MaxXEdge: + case .maxXEdge: return CGPoint(x: x + dx, y: y + dy * 0.5) - case .MaxYEdge: + case .maxYEdge: return CGPoint(x: x + dx * 0.5, y: y + dy) } } /// Returns a rect of the specified size centered in this rect touching the specified corner. - public func align(size: CGSize, corner e1: CGRectEdge, _ e2: CGRectEdge) -> CGRect { + public func align(_ size: CGSize, corner e1: CGRectEdge, _ e2: CGRectEdge) -> CGRect { return CGRect(origin: alignedOrigin(size, corner: e1, e2), size: size) } - private func alignedOrigin(size: CGSize, corner e1: CGRectEdge, _ e2: CGRectEdge) -> CGPoint { + fileprivate func alignedOrigin(_ size: CGSize, corner e1: CGRectEdge, _ e2: CGRectEdge) -> CGPoint { let dx = width - size.width let dy = height - size.height switch (e1, e2) { - case (.MinXEdge, .MinYEdge), (.MinYEdge, .MinXEdge): + case (.minXEdge, .minYEdge), (.minYEdge, .minXEdge): return CGPoint(x: x, y: y) - case (.MaxXEdge, .MinYEdge), (.MinYEdge, .MaxXEdge): + case (.maxXEdge, .minYEdge), (.minYEdge, .maxXEdge): return CGPoint(x: x + dx, y: y) - case (.MinXEdge, .MaxYEdge), (.MaxYEdge, .MinXEdge): + case (.minXEdge, .maxYEdge), (.maxYEdge, .minXEdge): return CGPoint(x: x, y: y + dy) - case (.MaxXEdge, .MaxYEdge), (.MaxYEdge, .MaxXEdge): + case (.maxXEdge, .maxYEdge), (.maxYEdge, .maxXEdge): return CGPoint(x: x + dx, y: y + dy) default: preconditionFailure("Cannot align to this combination of edges") @@ -489,17 +489,17 @@ extension CGRect { } /// Modifies all values by setting the size while centering the rect. - public mutating func centerInPlace(size: CGSize) { + public mutating func centerInPlace(_ size: CGSize) { self = center(size) } /// Modifies all values by setting the size while centering the rect touching the specified edge. - public mutating func centerInPlace(size: CGSize, alignTo edge: CGRectEdge) { + public mutating func centerInPlace(_ size: CGSize, alignTo edge: CGRectEdge) { self = center(size, alignTo: edge) } /// Modifies all values by setting the size while centering the rect touching the specified corner. - public mutating func alignInPlace(size: CGSize, corner e1: CGRectEdge, _ e2: CGRectEdge) { + public mutating func alignInPlace(_ size: CGSize, corner e1: CGRectEdge, _ e2: CGRectEdge) { self = align(size, corner: e1, e2) } } @@ -526,7 +526,7 @@ public func +(p1: CGPoint, p2: CGPoint) -> CGPoint { return CGPoint(x: p1.x + p2.x, y: p1.y + p2.y) } /// Modifies the x and y values by adding the coordinates of another point. -public func +=(inout p1: CGPoint, p2: CGPoint) { +public func +=(p1: inout CGPoint, p2: CGPoint) { p1.x += p2.x p1.y += p2.y } @@ -535,7 +535,7 @@ public func -(p1: CGPoint, p2: CGPoint) -> CGPoint { return CGPoint(x: p1.x - p2.x, y: p1.y - p2.y) } /// Modifies the x and y values by subtracting the coordinates of another points. -public func -=(inout p1: CGPoint, p2: CGPoint) { +public func -=(p1: inout CGPoint, p2: CGPoint) { p1.x -= p2.x p1.y -= p2.y } @@ -545,7 +545,7 @@ public func +(point: CGPoint, size: CGSize) -> CGPoint { return CGPoint(x: point.x + size.width, y: point.y + size.height) } /// Modifies the x and y values by adding a size to the coordinates. -public func +=(inout point: CGPoint, size: CGSize) { +public func +=(point: inout CGPoint, size: CGSize) { point.x += size.width point.y += size.height } @@ -554,7 +554,7 @@ public func -(point: CGPoint, size: CGSize) -> CGPoint { return CGPoint(x: point.x - size.width, y: point.y - size.height) } /// Modifies the x and y values by subtracting a size from the coordinates. -public func -=(inout point: CGPoint, size: CGSize) { +public func -=(point: inout CGPoint, size: CGSize) { point.x -= size.width point.y -= size.height } @@ -564,7 +564,7 @@ public func +(point: CGPoint, tuple: (CGFloat, CGFloat)) -> CGPoint { return CGPoint(x: point.x + tuple.0, y: point.y + tuple.1) } /// Modifies the x and y values by adding a tuple to the coordinates. -public func +=(inout point: CGPoint, tuple: (CGFloat, CGFloat)) { +public func +=(point: inout CGPoint, tuple: (CGFloat, CGFloat)) { point.x += tuple.0 point.y += tuple.1 } @@ -573,7 +573,7 @@ public func -(point: CGPoint, tuple: (CGFloat, CGFloat)) -> CGPoint { return CGPoint(x: point.x - tuple.0, y: point.y - tuple.1) } /// Modifies the x and y values by subtracting a tuple from the coordinates. -public func -=(inout point: CGPoint, tuple: (CGFloat, CGFloat)) { +public func -=(point: inout CGPoint, tuple: (CGFloat, CGFloat)) { point.x -= tuple.0 point.y -= tuple.1 } @@ -582,7 +582,7 @@ public func *(point: CGPoint, factor: CGFloat) -> CGPoint { return CGPoint(x: point.x * factor, y: point.y * factor) } /// Modifies the x and y values by multiplying the coordinates with a value. -public func *=(inout point: CGPoint, factor: CGFloat) { +public func *=(point: inout CGPoint, factor: CGFloat) { point.x *= factor point.y *= factor } @@ -591,7 +591,7 @@ public func *(point: CGPoint, tuple: (CGFloat, CGFloat)) -> CGPoint { return CGPoint(x: point.x * tuple.0, y: point.y * tuple.1) } /// Modifies the x and y values by multiplying the coordinates with a tuple. -public func *=(inout point: CGPoint, tuple: (CGFloat, CGFloat)) { +public func *=(point: inout CGPoint, tuple: (CGFloat, CGFloat)) { point.x *= tuple.0 point.y *= tuple.1 } @@ -600,7 +600,7 @@ public func /(point: CGPoint, tuple: (CGFloat, CGFloat)) -> CGPoint { return CGPoint(x: point.x / tuple.0, y: point.y / tuple.1) } /// Modifies the x and y values by dividing the coordinates by a tuple. -public func /=(inout point: CGPoint, tuple: (CGFloat, CGFloat)) { +public func /=(point: inout CGPoint, tuple: (CGFloat, CGFloat)) { point.x /= tuple.0 point.y /= tuple.1 } @@ -609,7 +609,7 @@ public func /(point: CGPoint, factor: CGFloat) -> CGPoint { return CGPoint(x: point.x / factor, y: point.y / factor) } /// Modifies the x and y values by dividing the coordinates by a factor. -public func /=(inout point: CGPoint, factor: CGFloat) { +public func /=(point: inout CGPoint, factor: CGFloat) { point.x /= factor point.y /= factor } @@ -619,7 +619,7 @@ public func +(s1: CGSize, s2: CGSize) -> CGSize { return CGSize(width: s1.width + s2.width, height: s1.height + s2.height) } /// Modifies the width and height values by adding another size. -public func +=(inout s1: CGSize, s2: CGSize) { +public func +=(s1: inout CGSize, s2: CGSize) { s1.width += s2.width s1.height += s2.height } @@ -628,7 +628,7 @@ public func -(s1: CGSize, s2: CGSize) -> CGSize { return CGSize(width: s1.width - s2.width, height: s1.height - s2.height) } /// Modifies the width and height values by subtracting another size. -public func -=(inout s1: CGSize, s2: CGSize) { +public func -=(s1: inout CGSize, s2: CGSize) { s1.width -= s2.width s1.height -= s2.height } @@ -638,7 +638,7 @@ public func +(size: CGSize, tuple: (CGFloat, CGFloat)) -> CGSize { return CGSize(width: size.width + tuple.0, height: size.height + tuple.1) } /// Modifies the width and height values by adding a tuple. -public func +=(inout size: CGSize, tuple: (CGFloat, CGFloat)) { +public func +=(size: inout CGSize, tuple: (CGFloat, CGFloat)) { size.width += tuple.0 size.height += tuple.1 } @@ -647,7 +647,7 @@ public func -(size: CGSize, tuple: (CGFloat, CGFloat)) -> CGSize { return CGSize(width: size.width - tuple.0, height: size.height - tuple.1) } /// Modifies the width and height values by subtracting a tuple. -public func -=(inout size: CGSize, tuple: (CGFloat, CGFloat)) { +public func -=(size: inout CGSize, tuple: (CGFloat, CGFloat)) { size.width -= tuple.0 size.height -= tuple.1 } @@ -656,7 +656,7 @@ public func *(size: CGSize, factor: CGFloat) -> CGSize { return CGSize(width: size.width * factor, height: size.height * factor) } /// Modifies the width and height values by multiplying them with a factor. -public func *=(inout size: CGSize, factor: CGFloat) { +public func *=(size: inout CGSize, factor: CGFloat) { size.width *= factor size.height *= factor } @@ -665,7 +665,7 @@ public func *(size: CGSize, tuple: (CGFloat, CGFloat)) -> CGSize { return CGSize(width: size.width * tuple.0, height: size.height * tuple.1) } /// Modifies the width and height values by multiplying them with a tuple. -public func *=(inout size: CGSize, tuple: (CGFloat, CGFloat)) { +public func *=(size: inout CGSize, tuple: (CGFloat, CGFloat)) { size.width *= tuple.0 size.height *= tuple.1 } @@ -674,7 +674,7 @@ public func /(size: CGSize, factor: CGFloat) -> CGSize { return CGSize(width: size.width / factor, height: size.height / factor) } /// Modifies the width and height values by dividing them by a factor. -public func /=(inout size: CGSize, factor: CGFloat) { +public func /=(size: inout CGSize, factor: CGFloat) { size.width /= factor size.height /= factor } @@ -683,7 +683,7 @@ public func /(size: CGSize, tuple: (CGFloat, CGFloat)) -> CGSize { return CGSize(width: size.width / tuple.0, height: size.height / tuple.1) } /// Modifies the width and height values by dividing them by a tuple. -public func /=(inout size: CGSize, tuple: (CGFloat, CGFloat)) { +public func /=(size: inout CGSize, tuple: (CGFloat, CGFloat)) { size.width /= tuple.0 size.height /= tuple.1 } @@ -693,7 +693,7 @@ public func +(rect: CGRect, point: CGPoint) -> CGRect { return CGRect(origin: rect.origin + point, size: rect.size) } /// Modifies the x and y values by adding the coordinates of a point. -public func +=(inout rect: CGRect, point: CGPoint) { +public func +=(rect: inout CGRect, point: CGPoint) { rect.origin += point } /// Returns a rect by subtracting the coordinates of a point from the origin. @@ -701,7 +701,7 @@ public func -(rect: CGRect, point: CGPoint) -> CGRect { return CGRect(origin: rect.origin - point, size: rect.size) } /// Modifies the x and y values by subtracting the coordinates from a point. -public func -=(inout rect: CGRect, point: CGPoint) { +public func -=(rect: inout CGRect, point: CGPoint) { rect.origin -= point } @@ -710,7 +710,7 @@ public func +(rect: CGRect, size: CGSize) -> CGRect { return CGRect(origin: rect.origin, size: rect.size + size) } /// Modifies the width and height values by adding a size. -public func +=(inout rect: CGRect, size: CGSize) { +public func +=(rect: inout CGRect, size: CGSize) { rect.size += size } /// Returns a rect by subtracting a size from the size. @@ -718,40 +718,40 @@ public func -(rect: CGRect, size: CGSize) -> CGRect { return CGRect(origin: rect.origin, size: rect.size - size) } /// Modifies the width and height values by subtracting a size. -public func -=(inout rect: CGRect, size: CGSize) { +public func -=(rect: inout CGRect, size: CGSize) { rect.size -= size } /// Returns a point by applying a transform. public func *(point: CGPoint, transform: CGAffineTransform) -> CGPoint { - return CGPointApplyAffineTransform(point, transform) + return point.applying(transform) } /// Modifies all values by applying a transform. -public func *=(inout point: CGPoint, transform: CGAffineTransform) { - point = CGPointApplyAffineTransform(point, transform) +public func *=(point: inout CGPoint, transform: CGAffineTransform) { + point = point.applying(transform) } /// Returns a size by applying a transform. public func *(size: CGSize, transform: CGAffineTransform) -> CGSize { - return CGSizeApplyAffineTransform(size, transform) + return size.applying(transform) } /// Modifies all values by applying a transform. -public func *=(inout size: CGSize, transform: CGAffineTransform) { - size = CGSizeApplyAffineTransform(size, transform) +public func *=(size: inout CGSize, transform: CGAffineTransform) { + size = size.applying(transform) } /// Returns a rect by applying a transform. public func *(rect: CGRect, transform: CGAffineTransform) -> CGRect { - return CGRectApplyAffineTransform(rect, transform) + return rect.applying(transform) } /// Modifies all values by applying a transform. -public func *=(inout rect: CGRect, transform: CGAffineTransform) { - rect = CGRectApplyAffineTransform(rect, transform) +public func *=(rect: inout CGRect, transform: CGAffineTransform) { + rect = rect.applying(transform) } /// Returns a transform by concatenating two transforms. public func *(t1: CGAffineTransform, t2: CGAffineTransform) -> CGAffineTransform { - return CGAffineTransformConcat(t1, t2) + return t1.concatenating(t2) } /// Modifies all values by concatenating another transform. -public func *=(inout t1: CGAffineTransform, t2: CGAffineTransform) { - t1 = CGAffineTransformConcat(t1, t2) +public func *=(t1: inout CGAffineTransform, t2: CGAffineTransform) { + t1 = t1.concatenating(t2) } diff --git a/CGRectExtensionsTests/OperatorTests.swift b/CGRectExtensionsTests/OperatorTests.swift index c4d13b2..080156b 100644 --- a/CGRectExtensionsTests/OperatorTests.swift +++ b/CGRectExtensionsTests/OperatorTests.swift @@ -220,15 +220,15 @@ class RectOperatorTests: XCTestCase { class TransformOperatorTests: XCTestCase { - let transform = CGAffineTransformMakeScale(2, 3) + let transform = CGAffineTransform(scaleX: 2, y: 3) func testEquatable() { - let otherTransform = CGAffineTransformMakeScale(2, 3) + let otherTransform = CGAffineTransform(scaleX: 2, y: 3) XCTAssertTrue(transform == otherTransform) } func testNotEquatable() { - let otherTransform = CGAffineTransformMakeScale(3, 2) + let otherTransform = CGAffineTransform(scaleX: 3, y: 2) XCTAssertFalse(transform == otherTransform) } @@ -266,17 +266,17 @@ class TransformOperatorTests: XCTestCase { } func testMultiplyTransform() { - let otherTransform = CGAffineTransformMakeTranslation(10, 20) + let otherTransform = CGAffineTransform(translationX: 10, y: 20) XCTAssertEqual( otherTransform * transform, - CGAffineTransformConcat(otherTransform, transform)) + otherTransform.concatenating(transform)) } func testMultiplyTransformAssignment() { - var otherTransform = CGAffineTransformMakeTranslation(10, 20) + var otherTransform = CGAffineTransform(translationX: 10, y: 20) otherTransform *= transform XCTAssertEqual( otherTransform, - CGAffineTransformConcat(CGAffineTransformMakeTranslation(10, 20), transform)) + CGAffineTransform(translationX: 10, y: 20).concatenating(transform)) } } diff --git a/CGRectExtensionsTests/SizesTests.swift b/CGRectExtensionsTests/SizesTests.swift index 1d0ea26..e6b196f 100644 --- a/CGRectExtensionsTests/SizesTests.swift +++ b/CGRectExtensionsTests/SizesTests.swift @@ -13,56 +13,56 @@ class SizesTests: XCTestCase { func testCenteringAtMinX() { XCTAssertEqual( - rect.center(CGSize(width: 5, height: 8), alignTo: .MinXEdge), + rect.center(CGSize(width: 5, height: 8), alignTo: .minXEdge), CGRect(x: 1, y: 8, width: 5, height: 8)) } func testCenteringAtMaxX() { XCTAssertEqual( - rect.center(CGSize(width: 5, height: 8), alignTo: .MaxXEdge), + rect.center(CGSize(width: 5, height: 8), alignTo: .maxXEdge), CGRect(x: 6, y: 8, width: 5, height: 8)) } func testCenteringAtMinY() { XCTAssertEqual( - rect.center(CGSize(width: 5, height: 8), alignTo: .MinYEdge), + rect.center(CGSize(width: 5, height: 8), alignTo: .minYEdge), CGRect(x: 3.5, y: 2, width: 5, height: 8)) } func testCenteringAtMaxY() { XCTAssertEqual( - rect.center(CGSize(width: 5, height: 8), alignTo: .MaxYEdge), + rect.center(CGSize(width: 5, height: 8), alignTo: .maxYEdge), CGRect(x: 3.5, y: 14, width: 5, height: 8)) } func testCenteringAtMinXMinY() { XCTAssertEqual( - rect.align(CGSize(width: 5, height: 8), corner: .MinXEdge, .MinYEdge), + rect.align(CGSize(width: 5, height: 8), corner: .minXEdge, .minYEdge), CGRect(x: 1, y: 2, width: 5, height: 8)) } func testCenteringAtMaxXMinY() { XCTAssertEqual( - rect.align(CGSize(width: 5, height: 8), corner: .MaxXEdge, .MinYEdge), + rect.align(CGSize(width: 5, height: 8), corner: .maxXEdge, .minYEdge), CGRect(x: 6, y: 2, width: 5, height: 8)) } func testCenteringAtMinXMaxY() { XCTAssertEqual( - rect.align(CGSize(width: 5, height: 8), corner: .MinXEdge, .MaxYEdge), + rect.align(CGSize(width: 5, height: 8), corner: .minXEdge, .maxYEdge), CGRect(x: 1, y: 14, width: 5, height: 8)) } func testCenteringAtMaxXMaxY() { XCTAssertEqual( - rect.align(CGSize(width: 5, height: 8), corner: .MaxXEdge, .MaxYEdge), + rect.align(CGSize(width: 5, height: 8), corner: .maxXEdge, .maxYEdge), CGRect(x: 6, y: 14, width: 5, height: 8)) } func testCenteringPermutation() { let combinations: [(CGRectEdge, CGRectEdge)] = [ - (.MinXEdge, .MinYEdge), (.MaxXEdge, .MinYEdge), - (.MinXEdge, .MaxYEdge), (.MaxXEdge, .MaxYEdge) + (.minXEdge, .minYEdge), (.maxXEdge, .minYEdge), + (.minXEdge, .maxYEdge), (.maxXEdge, .maxYEdge) ] for (edge1, edge2) in combinations { let size = CGSize(width: 5, height: 8) @@ -83,49 +83,49 @@ class MutatingSizesTests: XCTestCase { } func testCenteringAtMinX() { - rect.centerInPlace(CGSize(width: 5, height: 8), alignTo: .MinXEdge) + rect.centerInPlace(CGSize(width: 5, height: 8), alignTo: .minXEdge) XCTAssertEqual(rect, CGRect(x: 1, y: 8, width: 5, height: 8)) } func testCenteringAtMaxX() { - rect.centerInPlace(CGSize(width: 5, height: 8), alignTo: .MaxXEdge) + rect.centerInPlace(CGSize(width: 5, height: 8), alignTo: .maxXEdge) XCTAssertEqual(rect, CGRect(x: 6, y: 8, width: 5, height: 8)) } func testCenteringAtMinY() { - rect.centerInPlace(CGSize(width: 5, height: 8), alignTo: .MinYEdge) + rect.centerInPlace(CGSize(width: 5, height: 8), alignTo: .minYEdge) XCTAssertEqual(rect, CGRect(x: 3.5, y: 2, width: 5, height: 8)) } func testCenteringAtMaxY() { - rect.centerInPlace(CGSize(width: 5, height: 8), alignTo: .MaxYEdge) + rect.centerInPlace(CGSize(width: 5, height: 8), alignTo: .maxYEdge) XCTAssertEqual(rect, CGRect(x: 3.5, y: 14, width: 5, height: 8)) } func testCenteringAtMinXMinY() { - rect.alignInPlace(CGSize(width: 5, height: 8), corner: .MinXEdge, .MinYEdge) + rect.alignInPlace(CGSize(width: 5, height: 8), corner: .minXEdge, .minYEdge) XCTAssertEqual(rect, CGRect(x: 1, y: 2, width: 5, height: 8)) } func testCenteringAtMaxXMinY() { - rect.alignInPlace(CGSize(width: 5, height: 8), corner: .MaxXEdge, .MinYEdge) + rect.alignInPlace(CGSize(width: 5, height: 8), corner: .maxXEdge, .minYEdge) XCTAssertEqual(rect, CGRect(x: 6, y: 2, width: 5, height: 8)) } func testCenteringAtMinXMaxY() { - rect.alignInPlace(CGSize(width: 5, height: 8), corner: .MinXEdge, .MaxYEdge) + rect.alignInPlace(CGSize(width: 5, height: 8), corner: .minXEdge, .maxYEdge) XCTAssertEqual(rect, CGRect(x: 1, y: 14, width: 5, height: 8)) } func testCenteringAtMaxXMaxY() { - rect.alignInPlace(CGSize(width: 5, height: 8), corner: .MaxXEdge, .MaxYEdge) + rect.alignInPlace(CGSize(width: 5, height: 8), corner: .maxXEdge, .maxYEdge) XCTAssertEqual(rect, CGRect(x: 6, y: 14, width: 5, height: 8)) } func testCenteringPermutation() { let combinations: [(CGRectEdge, CGRectEdge)] = [ - (.MinXEdge, .MinYEdge), (.MaxXEdge, .MinYEdge), - (.MinXEdge, .MaxYEdge), (.MaxXEdge, .MaxYEdge) + (.minXEdge, .minYEdge), (.maxXEdge, .minYEdge), + (.minXEdge, .maxYEdge), (.maxXEdge, .maxYEdge) ] let size = CGSize(width: 5, height: 8) for (edge1, edge2) in combinations { From 3681fe44644ac968ddff3b291e8f2ecf227361e7 Mon Sep 17 00:00:00 2001 From: Darius Jankauskas Date: Wed, 14 Sep 2016 11:44:47 +0100 Subject: [PATCH 2/4] new implementations for offsetInPlace(_:_:) and insetInPlace(dx:dy:) as they were removed in swift 3 --- CGRectExtensions/CGRectExtensions.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CGRectExtensions/CGRectExtensions.swift b/CGRectExtensions/CGRectExtensions.swift index 40679bb..67a14f9 100644 --- a/CGRectExtensions/CGRectExtensions.swift +++ b/CGRectExtensions/CGRectExtensions.swift @@ -252,7 +252,7 @@ extension CGRect { /// Modifies the x and y values by offsetting. public mutating func offsetInPlace(_ dx: CGFloat, _ dy: CGFloat) { - offsetInPlace(dx, dy) + self = self.offsetBy(dx: dx, dy: dy) } /// Modifies the x value values by offsetting. public mutating func offsetInPlace(dx: CGFloat = 0) { @@ -314,6 +314,11 @@ extension CGRect { return insetBy(bottom: bottomRight.height, right: bottomRight.width) } + /// Modifies all values by insetting all edges (left & right by dx, top & bottom by dy) + public mutating func insetInPlace(dx: CGFloat, dy: CGFloat) { + self = self.insetBy(dx: dx, dy: dy) + } + /// Modifies all values by insetting all edges by the same value. public mutating func insetInPlace(_ by: CGFloat) { insetInPlace(dx: by, dy: by) From 49135d9b9f03a75ef64c8d2ce076c8b530318766 Mon Sep 17 00:00:00 2001 From: Darius Jankauskas Date: Wed, 14 Sep 2016 11:48:18 +0100 Subject: [PATCH 3/4] removed redundant equality operator for CGAffineTransform (built-in in swift 3) --- CGRectExtensions/CGRectExtensions.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CGRectExtensions/CGRectExtensions.swift b/CGRectExtensions/CGRectExtensions.swift index 67a14f9..a885e59 100644 --- a/CGRectExtensions/CGRectExtensions.swift +++ b/CGRectExtensions/CGRectExtensions.swift @@ -511,11 +511,7 @@ extension CGRect { // MARK: transform -extension CGAffineTransform: Equatable { -} - -public func ==(t1: CGAffineTransform, t2: CGAffineTransform) -> Bool { - return CGAffineTransformEqualToTransform(t1, t2) +extension CGAffineTransform { } extension CGAffineTransform: CustomDebugStringConvertible { From a165f7cd1fc76bcd3fe6f3b9c54ab98088d3616c Mon Sep 17 00:00:00 2001 From: Darius Jankauskas Date: Wed, 14 Sep 2016 11:45:52 +0100 Subject: [PATCH 4/4] fixed the order of optional parameters (required in swift 3) --- CGRectExtensions/CGRectExtensions.swift | 6 +++--- CGRectExtensionsTests/ExtendTests.swift | 12 ++++++------ CGRectExtensionsTests/InsetTests.swift | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CGRectExtensions/CGRectExtensions.swift b/CGRectExtensions/CGRectExtensions.swift index a885e59..1e4b2aa 100644 --- a/CGRectExtensions/CGRectExtensions.swift +++ b/CGRectExtensions/CGRectExtensions.swift @@ -307,7 +307,7 @@ extension CGRect { } /// Returns a copy inset on the bottom and left edges. public func insetBy(bottomLeft: CGSize) -> CGRect { - return insetBy(bottom: bottomLeft.height, left: bottomLeft.width) + return insetBy(left: bottomLeft.width, bottom: bottomLeft.height) } /// Returns a copy inset on the bottom and right edges. public func insetBy(bottomRight: CGSize) -> CGRect { @@ -395,7 +395,7 @@ extension CGRect { } /// Modifies all values by extending the bottom and left edges. public func extendBy(bottomLeft: CGSize) -> CGRect { - return insetBy(bottom: -bottomLeft.height, left: -bottomLeft.width) + return insetBy(left: -bottomLeft.width, bottom: -bottomLeft.height) } /// Modifies all values by extending the bottom and right edges. public func extendBy(bottomRight: CGSize) -> CGRect { @@ -435,7 +435,7 @@ extension CGRect { } /// Modifies all values by extending the bottom and left edges. public mutating func extendInPlace(bottomLeft: CGSize) { - self = insetBy(bottom: -bottomLeft.height, left: -bottomLeft.width) + self = insetBy(left: -bottomLeft.width, bottom: -bottomLeft.height) } /// Modifies all values by extending the bottom and right edges. public mutating func extendInPlace(bottomRight: CGSize) { diff --git a/CGRectExtensionsTests/ExtendTests.swift b/CGRectExtensionsTests/ExtendTests.swift index c3ab897..87bc115 100644 --- a/CGRectExtensionsTests/ExtendTests.swift +++ b/CGRectExtensionsTests/ExtendTests.swift @@ -48,7 +48,7 @@ class ExtendTests: XCTestCase { func testExtendingMaxXMinY() { XCTAssertEqual( - rect.extendBy(maxX: -5, minY: -10), + rect.extendBy(minY: -10, maxX: -5), CGRect(x: 1, y: 12, width: 15, height: 30)) } @@ -98,7 +98,7 @@ class ExtendPlatformTests: ExtendTests { func testExtendingBottomLeft() { XCTAssertEqual( - rect.extendBy(bottom: -10, left: -5), + rect.extendBy(left: -5, bottom: -10), CGRect(x: 6, y: 12, width: 15, height: 30)) } @@ -159,7 +159,7 @@ class ExtendPlatformTests: ExtendTests { func testExtendingBottomLeft() { XCTAssertEqual( - rect.extendBy(bottom: -10, left: -5), + rect.extendBy(left: -5, bottom: -10), CGRect(x: 6, y: 2, width: 15, height: 30)) } @@ -244,7 +244,7 @@ class MutatingExtendTests: XCTestCase { } func testExtendtingMaxXMinY() { - rect.extendInPlace(maxX: -5, minY: -10) + rect.extendInPlace(minY: -10, maxX: -5) XCTAssertEqual(rect, CGRect(x: 1, y: 12, width: 15, height: 30)) } @@ -293,7 +293,7 @@ class MutatingExtendPlatformTests: MutatingExtendTests { } func testExtendtingBottomLeft() { - rect.extendInPlace(bottom: -10, left: -5) + rect.extendInPlace(left: -5, bottom: -10) XCTAssertEqual(rect, CGRect(x: 6, y: 12, width: 15, height: 30)) } @@ -346,7 +346,7 @@ class MutatingExtendPlatformTests: MutatingExtendTests { } func testExtendtingBottomLeft() { - rect.extendInPlace(bottom: -10, left: -5) + rect.extendInPlace(left: -5, bottom: -10) XCTAssertEqual(rect, CGRect(x: 6, y: 2, width: 15, height: 30)) } diff --git a/CGRectExtensionsTests/InsetTests.swift b/CGRectExtensionsTests/InsetTests.swift index 9893f49..81e45f2 100644 --- a/CGRectExtensionsTests/InsetTests.swift +++ b/CGRectExtensionsTests/InsetTests.swift @@ -42,7 +42,7 @@ class InsetTests: XCTestCase { func testInsettingMaxXMinY() { XCTAssertEqual( - rect.insetBy(maxX: 5, minY: 10), + rect.insetBy(minY: 10, maxX: 5), CGRect(x: 1, y: 12, width: 15, height: 30)) } @@ -92,7 +92,7 @@ class InsetPlatformTests: InsetTests { func testInsettingBottomLeft() { XCTAssertEqual( - rect.insetBy(bottom: 10, left: 5), + rect.insetBy(left: 5, bottom: 10), CGRect(x: 6, y: 12, width: 15, height: 30)) } @@ -151,7 +151,7 @@ class InsetPlatformTests: InsetTests { func testInsettingBottomLeft() { XCTAssertEqual( - rect.insetBy(bottom: 10, left: 5), + rect.insetBy(left: 5, bottom: 10), CGRect(x: 6, y: 2, width: 15, height: 30)) } @@ -236,7 +236,7 @@ class MutatingInsetTests: XCTestCase { } func testInsettingMaxXMinY() { - rect.insetInPlace(maxX: 5, minY: 10) + rect.insetInPlace(minY: 10, maxX: 5) XCTAssertEqual(rect, CGRect(x: 1, y: 12, width: 15, height: 30)) } @@ -285,7 +285,7 @@ class MutatingInsetPlatformTests: MutatingInsetTests { } func testInsettingBottomLeft() { - rect.insetInPlace(bottom: 10, left: 5) + rect.insetInPlace(left: 5, bottom: 10) XCTAssertEqual(rect, CGRect(x: 6, y: 12, width: 15, height: 30)) } @@ -338,7 +338,7 @@ class MutatingInsetPlatformTests: MutatingInsetTests { } func testInsettingBottomLeft() { - rect.insetInPlace(bottom: 10, left: 5) + rect.insetInPlace(left: 5, bottom: 10) XCTAssertEqual(rect, CGRect(x: 6, y: 2, width: 15, height: 30)) }