Skip to content

Commit 752abd7

Browse files
authored
Make ByteBufferQUICBinaryEncodingStrategyTests compatible with 32-bit systems (#2904)
This is a followup to #2867 Some of the literals used in the test cases were too big to fit in an Int32 This is fine on 64-bit systems, because the literals are considered as `Int`, which is Int64 on those systems However, on 32-bit systems, those literals are considered as Int64 Change: Add `as Int64` where needed, to tell the compiler we want these literals to be treated as Int64, which should allow these tests to run on 32 bit systems too
1 parent bee38df commit 752abd7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Tests/NIOCoreTests/ByteBufferQUICBinaryEncodingStrategyTests.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
6161
func testWriteFourByteQUICVariableLengthInteger() {
6262
var buffer = ByteBuffer()
6363
let strategy = ByteBuffer.QUICBinaryEncodingStrategy.quic
64-
let bytesWritten = strategy.writeInteger(0b00011101_01111111_00111110_01111101, to: &buffer)
64+
let bytesWritten = strategy.writeInteger(0b00011101_01111111_00111110_01111101 as Int64, to: &buffer)
6565
XCTAssertEqual(bytesWritten, 4)
6666
// 2 bit mask is 10 for 4 bytes so this becomes 0b10011101_01111111_00111110_01111101
6767
XCTAssertEqual(buffer.readInteger(as: UInt32.self), 0b10011101_01111111_00111110_01111101)
@@ -72,7 +72,7 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
7272
var buffer = ByteBuffer()
7373
let strategy = ByteBuffer.QUICBinaryEncodingStrategy.quic
7474
let bytesWritten = strategy.writeInteger(
75-
0b00000010_00011001_01111100_01011110_11111111_00010100_11101000_10001100,
75+
0b00000010_00011001_01111100_01011110_11111111_00010100_11101000_10001100 as Int64,
7676
to: &buffer
7777
)
7878
XCTAssertEqual(bytesWritten, 8)
@@ -99,7 +99,8 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
9999
func testRoundtripWithReservedCapacity() {
100100
// This test makes sure that a number encoded with more space than necessary can still be decoded as normal
101101
for reservedCapacity in [0, 1, 2, 4, 8] {
102-
for testNumber in [0, 63, 15293, 494_878_333, 151_288_809_941_952_652] {
102+
let testNumbers: [Int64] = [0, 63, 15293, 494_878_333, 151_288_809_941_952_652]
103+
for testNumber in testNumbers {
103104
var buffer = ByteBuffer()
104105
let strategy = ByteBuffer.QUICBinaryEncodingStrategy.quic
105106
let bytesWritten = strategy.writeInteger(
@@ -127,10 +128,11 @@ final class ByteBufferQUICBinaryEncodingStrategyTests: XCTestCase {
127128

128129
func testWriteReadQUICVariableLengthInteger() {
129130
let strategy = ByteBuffer.QUICBinaryEncodingStrategy.quic
130-
for integer in [37, 15293, 494_878_333, 151_288_809_941_952_652] {
131+
let testNumbers: [Int64] = [37, 15293, 494_878_333, 151_288_809_941_952_652]
132+
for integer in testNumbers {
131133
var buffer = ByteBuffer()
132134
_ = strategy.writeInteger(integer, to: &buffer)
133-
XCTAssertEqual(strategy.readInteger(as: Int.self, from: &buffer), integer)
135+
XCTAssertEqual(strategy.readInteger(as: Int64.self, from: &buffer), integer)
134136
}
135137
}
136138
}

0 commit comments

Comments
 (0)