@@ -16,13 +16,12 @@ import XCTest
16
16
import Foundation
17
17
18
18
final class Test_ServerSentEventsDecoding : Test_Runtime {
19
- func _test( input: String , output: [ ServerSentEvent ] , file: StaticString = #filePath, line: UInt = #line, while predicate: ( ArraySlice < UInt8 > ) -> Bool = { _ in true } , eventCountOffset : Int = 0 )
19
+ func _test( input: String , output: [ ServerSentEvent ] , file: StaticString = #filePath, line: UInt = #line, while predicate: @escaping @ Sendable ( ArraySlice < UInt8 > ) -> Bool = { _ in true } )
20
20
async throws
21
21
{
22
- let sequence = asOneBytePerElementSequence ( ArraySlice ( input. utf8) ) . asDecodedServerSentEvents ( )
22
+ let sequence = asOneBytePerElementSequence ( ArraySlice ( input. utf8) ) . asDecodedServerSentEvents ( while : predicate )
23
23
let events = try await [ ServerSentEvent] ( collecting: sequence)
24
- let eventCount = events. count + eventCountOffset
25
- XCTAssertEqual ( eventCount, output. count, file: file, line: line)
24
+ XCTAssertEqual ( events. count, output. count, file: file, line: line)
26
25
for (index, linePair) in zip ( events, output) . enumerated ( ) {
27
26
let ( actualEvent, expectedEvent) = linePair
28
27
XCTAssertEqual ( actualEvent, expectedEvent, " Event: \( index) " , file: file, line: line)
@@ -103,8 +102,7 @@ final class Test_ServerSentEventsDecoding: Test_Runtime {
103
102
] ,
104
103
while: { incomingData in
105
104
incomingData != ArraySlice < UInt8 > ( Data ( " [DONE] " . utf8) )
106
- } ,
107
- eventCountOffset: - 2
105
+ }
108
106
)
109
107
}
110
108
func _testJSONData< JSONType: Decodable & Hashable & Sendable > (
0 commit comments