@@ -23,7 +23,7 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
23
23
// One byte, ie less than 63, just write out as-is
24
24
for number in 0 ..< 63 {
25
25
var buffer = ByteBuffer ( )
26
- let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( reservedCapacity : 0 )
26
+ let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( requiredBytesHint : 0 )
27
27
let bytesWritten = strategy. writeInteger ( number, to: & buffer)
28
28
XCTAssertEqual ( bytesWritten, 1 )
29
29
XCTAssertEqual ( strategy. readInteger ( as: UInt8 . self, from: & buffer) , UInt8 ( number) )
@@ -33,7 +33,7 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
33
33
34
34
func testWriteTwoByteQUICVariableLengthInteger( ) {
35
35
var buffer = ByteBuffer ( )
36
- let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( reservedCapacity : 0 )
36
+ let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( requiredBytesHint : 0 )
37
37
let bytesWritten = strategy. writeInteger ( 0b00111011_10111101 , to: & buffer)
38
38
XCTAssertEqual ( bytesWritten, 2 )
39
39
// We need to mask the first 2 bits with 01 to indicate this is a 2 byte integer
@@ -44,7 +44,7 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
44
44
45
45
func testWriteFourByteQUICVariableLengthInteger( ) {
46
46
var buffer = ByteBuffer ( )
47
- let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( reservedCapacity : 0 )
47
+ let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( requiredBytesHint : 0 )
48
48
let bytesWritten = strategy. writeInteger ( 0b00011101_01111111_00111110_01111101 , to: & buffer)
49
49
XCTAssertEqual ( bytesWritten, 4 )
50
50
// 2 bit mask is 10 for 4 bytes so this becomes 0b10011101_01111111_00111110_01111101
@@ -54,7 +54,7 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
54
54
55
55
func testWriteEightByteQUICVariableLengthInteger( ) {
56
56
var buffer = ByteBuffer ( )
57
- let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( reservedCapacity : 0 )
57
+ let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( requiredBytesHint : 0 )
58
58
let bytesWritten = strategy. writeInteger (
59
59
0b00000010_00011001_01111100_01011110_11111111_00010100_11101000_10001100 ,
60
60
to: & buffer
@@ -73,7 +73,7 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
73
73
func testWriteOneByteQUICVariableLengthIntegerWithTwoBytesReserved( ) {
74
74
// We only need one byte but the encoder will use 2 because we reserved 2
75
75
var buffer = ByteBuffer ( )
76
- let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( reservedCapacity : 0 )
76
+ let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( requiredBytesHint : 0 )
77
77
let bytesWritten = strategy. writeIntegerWithReservedCapacity ( 0b00000001 , reservedCapacity: 2 , to: & buffer)
78
78
XCTAssertEqual ( bytesWritten, 2 )
79
79
XCTAssertEqual ( buffer. readInteger ( as: UInt16 . self) , UInt16 ( 0b01000000_00000001 ) )
@@ -85,7 +85,7 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
85
85
for reservedCapacity in [ 0 , 1 , 2 , 4 , 8 ] {
86
86
for testNumber in [ 0 , 63 , 15293 , 494_878_333 , 151_288_809_941_952_652 ] {
87
87
var buffer = ByteBuffer ( )
88
- let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( reservedCapacity : 0 )
88
+ let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( requiredBytesHint : 0 )
89
89
let bytesWritten = strategy. writeIntegerWithReservedCapacity (
90
90
testNumber,
91
91
reservedCapacity: reservedCapacity,
@@ -102,12 +102,12 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
102
102
103
103
func testReadEmptyQUICVariableLengthInteger( ) {
104
104
var buffer = ByteBuffer ( )
105
- let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( reservedCapacity : 0 )
105
+ let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( requiredBytesHint : 0 )
106
106
XCTAssertNil ( strategy. readInteger ( as: Int . self, from: & buffer) )
107
107
}
108
108
109
109
func testWriteReadQUICVariableLengthInteger( ) {
110
- let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( reservedCapacity : 0 )
110
+ let strategy = ByteBuffer . QUICBinaryEncodingStrategy ( requiredBytesHint : 0 )
111
111
for integer in [ 37 , 15293 , 494_878_333 , 151_288_809_941_952_652 ] {
112
112
var buffer = ByteBuffer ( )
113
113
_ = strategy. writeInteger ( integer, to: & buffer)
0 commit comments