Skip to content

Commit

Permalink
Merge pull request #22 from tayloraswift/test-lowering-deployment-minima
Browse files Browse the repository at this point in the history
check if we can get away with keeping the old deployment minima
  • Loading branch information
tayloraswift authored Nov 19, 2024
2 parents 5550cee + 1df651d commit ea0b9fc
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand Down
95 changes: 68 additions & 27 deletions Sources/MD5Tests/Hashing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 15 additions & 5 deletions Sources/MD5Tests/ParsingAndFormatting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
}
}

0 comments on commit ea0b9fc

Please sign in to comment.