diff --git a/Package.swift b/Package.swift index c4a2c00..7fa7f62 100644 --- a/Package.swift +++ b/Package.swift @@ -3,7 +3,7 @@ import PackageDescription let package:Package = .init( name: "swift-hash", - platforms: [.macOS(.v14), .iOS(.v17), .tvOS(.v17), .visionOS(.v1), .watchOS(.v10)], + platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)], products: [ .library(name: "Base16", targets: ["Base16"]), .library(name: "Base64", targets: ["Base64"]), diff --git a/Sources/MD5Tests/Hashing.swift b/Sources/MD5Tests/Hashing.swift index 02db3fd..d70e473 100644 --- a/Sources/MD5Tests/Hashing.swift +++ b/Sources/MD5Tests/Hashing.swift @@ -5,39 +5,80 @@ import Testing @Suite struct Hashing { - @Test(arguments: [ - (0xd41d8cd98f00b204e9800998ecf8427e, []), - (0x0cc175b9c0f1b6a831c399e269772661, [0x61]), - (0x900150983cd24fb0d6963f7d28e17f72, [0x61, 0x62, 0x63]), - ] as [(MD5, [UInt8])]) + private + static var binary:[(MD5, [UInt8])] + { + if #available( + macOS 13.3, + macCatalyst 16.4, + iOS 16.4, + tvOS 16.4, + visionOS 1.0, + watchOS 9.4, + *) + { + [ + (0xd41d8cd98f00b204e9800998ecf8427e, []), + (0x0cc175b9c0f1b6a831c399e269772661, [0x61]), + (0x900150983cd24fb0d6963f7d28e17f72, [0x61, 0x62, 0x63]), + ] + } + else + { + [] + } + } + + @Test(arguments: Self.binary) static func binary(_ test:(expected:MD5, input:[UInt8])) { let md5:MD5 = .init(hashing: test.input) #expect(md5 == test.expected) } - @Test(arguments: [ - ( - 0xf96b697d7cb7938d525a2f31aaf161d0, - "message digest" - ), - ( - 0xc3fcd3d76192e4007dfb496cca67e13b, - "abcdefghijklmnopqrstuvwxyz" - ), - ( - 0xd174ab98d277d9f5a5611c2c9f419d9f, - """ - ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 - """ - ), - ( - 0x57edf4a22be3c955ac49da2e2107b67a, - """ - 12345678901234567890123456789012345678901234567890123456789012345678901234567890 - """ - ), - ] as [(MD5, String)]) + private + static var string:[(MD5, String)] + { + if #available( + macOS 13.3, + macCatalyst 16.4, + iOS 16.4, + tvOS 16.4, + visionOS 1.0, + watchOS 9.4, + *) + { + [ + ( + 0xf96b697d7cb7938d525a2f31aaf161d0, + "message digest" + ), + ( + 0xc3fcd3d76192e4007dfb496cca67e13b, + "abcdefghijklmnopqrstuvwxyz" + ), + ( + 0xd174ab98d277d9f5a5611c2c9f419d9f, + """ + ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 + """ + ), + ( + 0x57edf4a22be3c955ac49da2e2107b67a, + """ + 1234567890123456789012345678901234567890\ + 1234567890123456789012345678901234567890 + """ + ), + ] + } + else + { + [] + } + } + + @Test(arguments: Self.string) static func string(_ test:(expected:MD5, input:String)) { let md5:MD5 = .init(hashing: test.input.utf8) diff --git a/Sources/MD5Tests/ParsingAndFormatting.swift b/Sources/MD5Tests/ParsingAndFormatting.swift index 5e5030c..3351812 100644 --- a/Sources/MD5Tests/ParsingAndFormatting.swift +++ b/Sources/MD5Tests/ParsingAndFormatting.swift @@ -7,11 +7,21 @@ struct ParsingAndFormatting @Test static func strings() throws { - let string:String = "d41d8cd98f00b204e9800998ecf8427e" - let hash:MD5 = 0xd41d8cd98f00b204e9800998ecf8427e + if #available( + macOS 13.3, + macCatalyst 16.4, + iOS 16.4, + tvOS 16.4, + visionOS 1.0, + watchOS 9.4, + *) + { + let string:String = "d41d8cd98f00b204e9800998ecf8427e" + let hash:MD5 = 0xd41d8cd98f00b204e9800998ecf8427e - let parsed:MD5 = try #require(.init(string)) - #expect(parsed == hash) - #expect(string == "\(hash)") + let parsed:MD5 = try #require(.init(string)) + #expect(parsed == hash) + #expect(string == "\(hash)") + } } }