Skip to content

Commit 07bc52b

Browse files
committed
Add CorePlatformImageTests
1 parent 141998e commit 07bc52b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// CorePlatformImageTests.swift
3+
// OpenSwiftUI_SPITests
4+
5+
#if canImport(Darwin)
6+
import CoreGraphics
7+
import Foundation
8+
import OpenSwiftUI_SPI
9+
import OpenSwiftUICore
10+
import Testing
11+
12+
@MainActor
13+
struct CorePlatformImageTests {
14+
@Test
15+
func nilCGImage() {
16+
let image: NSObject
17+
#if os(iOS)
18+
image = UIImage()
19+
#elseif os(macOS)
20+
image = NSImage(size: CGSize(width: 100, height: 100))
21+
#endif
22+
let coreImage = CorePlatformImage(system: .appKit, kitImage: image)
23+
#expect(coreImage.cgImage == nil)
24+
#expect(coreImage.size == .zero)
25+
}
26+
27+
@Test
28+
func nonNilCGImage() {
29+
let image: NSObject
30+
#if os(iOS)
31+
image = UIImage.add
32+
#elseif os(macOS)
33+
image = NSImage(named: NSImage.addTemplateName)!
34+
#endif
35+
let coreImage = CorePlatformImage(system: .appKit, kitImage: image)
36+
#expect(coreImage.cgImage != nil)
37+
#expect(coreImage.size != .zero)
38+
}
39+
}
40+
41+
#endif

0 commit comments

Comments
 (0)