Skip to content

Commit 1a1b9ad

Browse files
authored
Update CGTypes and test case (#4)
1 parent d4fdffa commit 1a1b9ad

File tree

4 files changed

+63
-5
lines changed

4 files changed

+63
-5
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// CGPoint+Extension.swift
3+
// OpenCoreGraphics
4+
//
5+
6+
public import Foundation
7+
8+
#if canImport(Darwin)
9+
extension CGPoint {
10+
public static let zero = CGPoint(x: .zero, y: .zero)
11+
}
12+
#endif
13+
14+
extension CGPoint: Swift.CustomDebugStringConvertible {
15+
public var debugDescription: String {
16+
"(\(x.description), \(y.description))"
17+
}
18+
}

Sources/OpenCoreGraphics/Shims.swift renamed to Sources/OpenCoreGraphics/CGRect+Extension.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//
2-
// Shims.swift
2+
// CGRect+Extension.swift
33
// OpenCoreGraphics
44

5-
#if canImport(Darwin)
65
public import Foundation
76

7+
#if canImport(Darwin)
88
extension CGRect {
99
public init(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat) {
1010
self.init(origin: CGPoint(x: x, y: y), size: CGSize(width: width, height: height))
@@ -34,9 +34,12 @@ extension CGRect {
3434
return origin.y + size.height
3535
}
3636

37+
public static let zero = CGRect(origin: .zero, size: .zero)
3738
}
39+
#endif
3840

39-
extension CGPoint {
40-
public static let zero = CGPoint(x: .zero, y: .zero)
41+
extension CGRect: Swift.CustomDebugStringConvertible {
42+
public var debugDescription: String {
43+
"(\(origin.x.description), \(origin.y.description), \(size.width.description), \(size.height.description))"
44+
}
4145
}
42-
#endif
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// CGSize+Extension.swift
3+
// OpenCoreGraphics
4+
5+
public import Foundation
6+
7+
#if canImport(Darwin)
8+
extension CGSize {
9+
public static let zero = CGSize(width: .zero, height: .zero)
10+
}
11+
#endif
12+
13+
extension CGSize: Swift.CustomDebugStringConvertible {
14+
public var debugDescription: String {
15+
"(\(width.description), \(height.description))"
16+
}
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// CGTypesTests.swift
3+
// OpenCoreGraphics
4+
5+
import OpenCoreGraphicsShims
6+
import Testing
7+
8+
struct CGTypesTests {
9+
@Test
10+
func description() {
11+
let point = CGPoint(x: 1.0, y: 2.0)
12+
#expect(point.debugDescription == "(1.0, 2.0)")
13+
14+
let size = CGSize(width: 3.0, height: 4.0)
15+
#expect(size.debugDescription == "(3.0, 4.0)")
16+
17+
let rect = CGRect(x: 5.0, y: 6.0, width: 7.0, height: 8.0)
18+
#expect(rect.debugDescription == "(5.0, 6.0, 7.0, 8.0)")
19+
}
20+
}

0 commit comments

Comments
 (0)