Skip to content

Commit a8f42e0

Browse files
authored
Remove a few unintended Foundation dependencies from our unit tests. (#406)
This PR removes uses of Foundation's `String.Encoding.utf8` and `DataProtocol.copyBytes(to:)`. These dependencies on Foundation are not needed nor are they intentional. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent f5fd88e commit a8f42e0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Tests/TestingTests/ABIEntryPointTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct ABIEntryPointTests {
3838
arguments.filter = ["NonExistentTestThatMatchesNothingHopefully"]
3939
let argumentsJSON = try JSON.withEncoding(of: arguments) { argumentsJSON in
4040
let result = UnsafeMutableRawBufferPointer.allocate(byteCount: argumentsJSON.count, alignment: 1)
41-
argumentsJSON.copyBytes(to: result)
41+
_ = memcpy(result.baseAddress!, argumentsJSON.baseAddress!, argumentsJSON.count)
4242
return result
4343
}
4444
defer {

Tests/TestingTests/Test.Case.Argument.IDTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct Test_Case_Argument_IDTests {
2323
#expect(testCase.arguments.count == 1)
2424
let argument = try #require(testCase.arguments.first)
2525
let argumentID = try #require(argument.id)
26-
#expect(String(bytes: argumentID.bytes, encoding: .utf8) == "123")
26+
#expect(String(decoding: argumentID.bytes, as: UTF8.self) == "123")
2727
}
2828

2929
@Test("One CustomTestArgumentEncodable parameter")
@@ -56,7 +56,7 @@ struct Test_Case_Argument_IDTests {
5656
#expect(testCase.arguments.count == 1)
5757
let argument = try #require(testCase.arguments.first)
5858
let argumentID = try #require(argument.id)
59-
#expect(String(bytes: argumentID.bytes, encoding: .utf8) == #""abc""#)
59+
#expect(String(decoding: argumentID.bytes, as: UTF8.self) == #""abc""#)
6060
}
6161

6262
@Test("One RawRepresentable parameter")
@@ -70,7 +70,7 @@ struct Test_Case_Argument_IDTests {
7070
#expect(testCase.arguments.count == 1)
7171
let argument = try #require(testCase.arguments.first)
7272
let argumentID = try #require(argument.id)
73-
#expect(String(bytes: argumentID.bytes, encoding: .utf8) == #""abc""#)
73+
#expect(String(decoding: argumentID.bytes, as: UTF8.self) == #""abc""#)
7474
}
7575
}
7676

0 commit comments

Comments
 (0)