Skip to content

Commit 61d55cc

Browse files
authored
Merge branch 'main' into swift-6
2 parents 0158493 + 3766687 commit 61d55cc

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

Source/API/Utils/CrossPlattformGraphics.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@
7272
}
7373
}
7474

75-
public struct RectCorner: OptionSet, Sendable {
75+
public struct RectCorner: OptionSet {
7676
public static let topLeft: RectCorner = .init(rawValue: 1 << 0)
7777
public static let topRight: RectCorner = .init(rawValue: 1 << 1)
7878
public static let bottomLeft: RectCorner = .init(rawValue: 1 << 2)
7979
public static let bottomRight: RectCorner = .init(rawValue: 1 << 3)
80-
public static let allCorners: RectCorner = .init(rawValue: 1 << 4 - 1)
80+
public static let allCorners: RectCorner = .init(rawValue: (1 << 4) - 1)
8181

8282
let value: Int
8383

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//
2+
// RectCornerTests.swift
3+
// TPPDF_Tests
4+
//
5+
// Created by Philip Niedertscheider on 2025-12-29.
6+
// Copyright © 2016-2025 techprimate GmbH. All rights reserved.
7+
//
8+
9+
#if !os(iOS) && !os(tvOS) && !os(watchOS) && !os(visionOS)
10+
import Testing
11+
@testable import TPPDF
12+
13+
@Suite("RectCorner Tests")
14+
struct RectCornerTests {
15+
@Test("Individual corner raw values are correct")
16+
func testIndividualCornerRawValues() {
17+
#expect(RectCorner.topLeft.rawValue == 1) // 1 << 0 = 0b0001
18+
#expect(RectCorner.topRight.rawValue == 2) // 1 << 1 = 0b0010
19+
#expect(RectCorner.bottomLeft.rawValue == 4) // 1 << 2 = 0b0100
20+
#expect(RectCorner.bottomRight.rawValue == 8) // 1 << 3 = 0b1000
21+
}
22+
23+
@Test("allCorners raw value is correct")
24+
func testAllCornersRawValue() {
25+
// allCorners should be (1 << 4) - 1 = 16 - 1 = 15 = 0b1111
26+
#expect(RectCorner.allCorners.rawValue == 15)
27+
}
28+
29+
@Test("allCorners contains all individual corners")
30+
func testAllCornersContainsAllCorners() {
31+
#expect(RectCorner.allCorners.contains(.topLeft))
32+
#expect(RectCorner.allCorners.contains(.topRight))
33+
#expect(RectCorner.allCorners.contains(.bottomLeft))
34+
#expect(RectCorner.allCorners.contains(.bottomRight))
35+
}
36+
37+
@Test("Can combine corners using OptionSet operations")
38+
func testCombineCorners() {
39+
let topCorners: RectCorner = [.topLeft, .topRight]
40+
#expect(topCorners.contains(.topLeft))
41+
#expect(topCorners.contains(.topRight))
42+
#expect(!topCorners.contains(.bottomLeft))
43+
#expect(!topCorners.contains(.bottomRight))
44+
45+
let bottomCorners: RectCorner = [.bottomLeft, .bottomRight]
46+
#expect(bottomCorners.contains(.bottomLeft))
47+
#expect(bottomCorners.contains(.bottomRight))
48+
#expect(!bottomCorners.contains(.topLeft))
49+
#expect(!bottomCorners.contains(.topRight))
50+
}
51+
52+
@Test("Can create RectCorner from raw value")
53+
func testInitFromRawValue() {
54+
let corner = RectCorner(rawValue: 1)
55+
#expect(corner.rawValue == 1)
56+
#expect(corner == .topLeft)
57+
58+
let allCornersFromRaw = RectCorner(rawValue: 15)
59+
#expect(allCornersFromRaw.rawValue == 15)
60+
#expect(allCornersFromRaw == .allCorners)
61+
}
62+
63+
@Test("Union of all individual corners equals allCorners")
64+
func testUnionEqualsAllCorners() {
65+
let combined: RectCorner = [.topLeft, .topRight, .bottomLeft, .bottomRight]
66+
#expect(combined.rawValue == RectCorner.allCorners.rawValue)
67+
#expect(combined == .allCorners)
68+
}
69+
}
70+
#endif

0 commit comments

Comments
 (0)