Skip to content

Commit e9b2bb3

Browse files
committed
Fix Darwin stringy bits
1 parent cf419da commit e9b2bb3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,16 @@ extension AttachableImageFormat.Kind: CustomStringConvertible, CustomDebugString
113113
}
114114

115115
package var description: String {
116-
contentType.localizedDescription
116+
let contentType = contentType
117+
return contentType.localizedDescription ?? contentType.identifier
117118
}
118119

119120
package var debugDescription: String {
120121
let contentType = contentType
121-
return "\(contentType.localizedDescription) (\(contentType.identifier))"
122+
if let localizedDescription = contentType.localizedDescription {
123+
return "\(localizedDescription) (\(contentType.identifier))"
124+
}
125+
return contentType.identifier
122126
}
123127
}
124128
#endif

Tests/TestingTests/AttachmentTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,8 @@ extension AttachmentTests {
874874
@Test func imageFormatStringification() {
875875
let format: AttachableImageFormat = AttachableImageFormat.png
876876
#if canImport(CoreGraphics) && canImport(_Testing_CoreGraphics)
877-
#expect(String(describing: format) == UTType.png.localizedDescription)
878-
#expect(String(reflecting: format) == "\(UTType.png.localizedDescription) (\(UTType.png.identifier))")
877+
#expect(String(describing: format) == UTType.png.localizedDescription!)
878+
#expect(String(reflecting: format) == "\(UTType.png.localizedDescription!) (\(UTType.png.identifier)) at quality 1.0")
879879
#elseif canImport(WinSDK) && canImport(_Testing_WinSDK)
880880
#expect(String(describing: format) == "PNG format")
881881
#expect(String(reflecting: format) == "PNG format (27949969-876a-41d7-9447-568f6a35a4dc) at quality 1.0")
@@ -886,8 +886,8 @@ extension AttachmentTests {
886886
@Test func imageFormatStringificationWithQuality() {
887887
let format: AttachableImageFormat = AttachableImageFormat.jpeg(withEncodingQuality: 0.5)
888888
#if canImport(CoreGraphics) && canImport(_Testing_CoreGraphics)
889-
#expect(String(describing: format) == "\(UTType.jpeg.localizedDescription) at 50% quality")
890-
#expect(String(reflecting: format) == "\(UTType.jpeg.localizedDescription) (\(UTType.jpeg.identifier)) at quality 0.5")
889+
#expect(String(describing: format) == "\(UTType.jpeg.localizedDescription!) at 50% quality")
890+
#expect(String(reflecting: format) == "\(UTType.jpeg.localizedDescription!) (\(UTType.jpeg.identifier)) at quality 0.5")
891891
#elseif canImport(WinSDK) && canImport(_Testing_WinSDK)
892892
#expect(String(describing: format) == "JPEG format at 50% quality")
893893
#expect(String(reflecting: format) == "JPEG format (1a34f5c1-4a5a-46dc-b644-1f4567e7a676) at quality 0.5")

0 commit comments

Comments
 (0)