Replace deprecated Data(bytes:)
This commit is contained in:
parent
8dfd5f23c1
commit
207a4f063a
|
@ -56,7 +56,7 @@ extension TunnelKitProvider {
|
|||
public let data: Data
|
||||
|
||||
private init(_ byte: UInt8) {
|
||||
data = Data(bytes: [byte])
|
||||
data = Data([byte])
|
||||
}
|
||||
|
||||
init(_ data: Data) {
|
||||
|
|
|
@ -66,7 +66,7 @@ extension Data {
|
|||
}
|
||||
bytes[index >> 1] |= nibble
|
||||
}
|
||||
self = Data(bytes: bytes)
|
||||
self = Data(bytes)
|
||||
}
|
||||
|
||||
func toHex() -> String {
|
||||
|
|
|
@ -41,7 +41,7 @@ class CompressionTests: XCTestCase {
|
|||
func testSymmetric() {
|
||||
XCTAssertTrue(LZOIsSupported());
|
||||
let lzo = LZOCreate()
|
||||
let src = Data(bytes: [UInt8](repeating: 6, count: 100))
|
||||
let src = Data([UInt8](repeating: 6, count: 100))
|
||||
guard let dst = try? lzo.compressedData(with: src) else {
|
||||
XCTFail("Uncompressible data")
|
||||
return
|
||||
|
|
|
@ -77,27 +77,27 @@ class LinkTests: XCTestCase {
|
|||
bytes.append(contentsOf: [0xaa])
|
||||
XCTAssertEqual(bytes.count, 21)
|
||||
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes: bytes))
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes))
|
||||
XCTAssertEqual(until, 18)
|
||||
XCTAssertEqual(packets.count, 3)
|
||||
|
||||
bytes.append(contentsOf: [0xbb, 0xcc])
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes: bytes))
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes))
|
||||
XCTAssertEqual(until, 23)
|
||||
XCTAssertEqual(packets.count, 4)
|
||||
|
||||
bytes.append(contentsOf: [0x00, 0x05])
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes: bytes))
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes))
|
||||
XCTAssertEqual(until, 23)
|
||||
XCTAssertEqual(packets.count, 4)
|
||||
|
||||
bytes.append(contentsOf: [0x11, 0x22, 0x33, 0x44])
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes: bytes))
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes))
|
||||
XCTAssertEqual(until, 23)
|
||||
XCTAssertEqual(packets.count, 4)
|
||||
|
||||
bytes.append(contentsOf: [0x55])
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes: bytes))
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes))
|
||||
XCTAssertEqual(until, 30)
|
||||
XCTAssertEqual(packets.count, 5)
|
||||
|
||||
|
@ -108,7 +108,7 @@ class LinkTests: XCTestCase {
|
|||
|
||||
bytes.append(contentsOf: [0x00, 0x04])
|
||||
bytes.append(contentsOf: [0x10, 0x20])
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes: bytes))
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes))
|
||||
XCTAssertEqual(until, 0)
|
||||
XCTAssertEqual(packets.count, 0)
|
||||
bytes.removeSubrange(0..<until)
|
||||
|
@ -117,7 +117,7 @@ class LinkTests: XCTestCase {
|
|||
bytes.append(contentsOf: [0x30, 0x40])
|
||||
bytes.append(contentsOf: [0x00, 0x07])
|
||||
bytes.append(contentsOf: [0x10, 0x20, 0x30, 0x40])
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes: bytes))
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes))
|
||||
XCTAssertEqual(until, 6)
|
||||
XCTAssertEqual(packets.count, 1)
|
||||
bytes.removeSubrange(0..<until)
|
||||
|
@ -128,14 +128,14 @@ class LinkTests: XCTestCase {
|
|||
bytes.append(contentsOf: [0xff])
|
||||
bytes.append(contentsOf: [0x00, 0x03])
|
||||
bytes.append(contentsOf: [0xaa])
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes: bytes))
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes))
|
||||
XCTAssertEqual(until, 12)
|
||||
XCTAssertEqual(packets.count, 2)
|
||||
bytes.removeSubrange(0..<until)
|
||||
XCTAssertEqual(bytes.count, 3)
|
||||
|
||||
bytes.append(contentsOf: [0xbb, 0xcc])
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes: bytes))
|
||||
(until, packets) = PacketStream.packets(from: Data(bytes))
|
||||
XCTAssertEqual(until, 5)
|
||||
XCTAssertEqual(packets.count, 1)
|
||||
bytes.removeSubrange(0..<until)
|
||||
|
|
Loading…
Reference in New Issue