@@ -254,6 +254,40 @@ final class GenerativeModelTests: XCTestCase {
254
254
XCTAssertEqual ( response. functionCalls, [ functionCall] )
255
255
}
256
256
257
+ func testGenerateContent_success_functionCall_parallelCalls( ) async throws {
258
+ MockURLProtocol
259
+ . requestHandler = try httpRequestHandler (
260
+ forResource: " unary-success-function-call-parallel-calls " ,
261
+ withExtension: " json "
262
+ )
263
+
264
+ let response = try await model. generateContent ( testPrompt)
265
+
266
+ XCTAssertEqual ( response. candidates. count, 1 )
267
+ let candidate = try XCTUnwrap ( response. candidates. first)
268
+ XCTAssertEqual ( candidate. content. parts. count, 3 )
269
+ let functionCalls = response. functionCalls
270
+ XCTAssertEqual ( functionCalls. count, 3 )
271
+ }
272
+
273
+ func testGenerateContent_success_functionCall_mixedContent( ) async throws {
274
+ MockURLProtocol
275
+ . requestHandler = try httpRequestHandler (
276
+ forResource: " unary-success-function-call-mixed-content " ,
277
+ withExtension: " json "
278
+ )
279
+
280
+ let response = try await model. generateContent ( testPrompt)
281
+
282
+ XCTAssertEqual ( response. candidates. count, 1 )
283
+ let candidate = try XCTUnwrap ( response. candidates. first)
284
+ XCTAssertEqual ( candidate. content. parts. count, 4 )
285
+ let functionCalls = response. functionCalls
286
+ XCTAssertEqual ( functionCalls. count, 2 )
287
+ let text = try XCTUnwrap ( response. text)
288
+ XCTAssertEqual ( text, " The sum of [1, 2, 3] is " )
289
+ }
290
+
257
291
func testGenerateContent_usageMetadata( ) async throws {
258
292
MockURLProtocol
259
293
. requestHandler = try httpRequestHandler (
0 commit comments