@@ -3,15 +3,15 @@ import XCTest
33import FunctionCalling
44import AIProxy
55
6- final class FunctionCalling_AIProxySwiftTests : XCTestCase {
7-
6+ final class FunctionCallingAIProxySwiftTests : XCTestCase {
7+
88 var toolContainer : ToolContainer !
99
1010 struct MockToolContainer : ToolContainer {
11- func execute( methodName name: String , parameters: [ String : Any ] ) async -> String {
11+ func execute( methodName name: String , parameters: [ String : Any ] ) async -> String {
1212 " "
1313 }
14-
14+
1515 let allTools : [ Tool ] ?
1616
1717 let allToolsJSONString : String = " "
@@ -29,18 +29,27 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
2929 inputSchema: . init(
3030 type: . object,
3131 properties: [
32- " testParam " : . init( type: . string, description: " A test parameter " , enumValues: [ " option1 " , " option2 " ] )
32+ " testParam " : . init(
33+ type: . string,
34+ description: " A test parameter " ,
35+ enumValues: [
36+ " option1 " ,
37+ " option2 "
38+ ]
39+ )
3340 ] ,
3441 requiredProperties: [ " testParam " ]
3542 )
3643 )
3744
3845 toolContainer = MockToolContainer ( allTools: [ tool] )
3946 }
40-
47+
48+ // swiftlint:disable cyclomatic_complexity
49+ // swiftlint:disable function_body_length
4150 func testToOpenAITools( ) throws {
4251 let openAITools = toolContainer. toOpenAITools ( )
43-
52+
4453 XCTAssertEqual ( openAITools. count, 1 )
4554
4655 let openAITool = try XCTUnwrap ( openAITools. first)
@@ -76,10 +85,10 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
7685 return
7786 }
7887
79- let requiredProperties = required. compactMap { r in
80- switch r {
81- case . string( let p ) :
82- return p
88+ let requiredProperties = required. compactMap { requiredProperty in
89+ switch requiredProperty {
90+ case . string( let propertyName ) :
91+ return propertyName
8392 default :
8493 return nil
8594 }
@@ -120,20 +129,20 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
120129
121130 XCTAssertEqual ( enumValueArray. count, 2 )
122131
123- let enumValues = enumValueArray. compactMap { e in
124- switch e {
125- case . string( let v ) :
126- return v
132+ let enumValues = enumValueArray. compactMap { enumValue in
133+ switch enumValue {
134+ case . string( let value ) :
135+ return value
127136 default :
128137 return nil
129138 }
130139 }
131140 XCTAssertEqual ( enumValues, [ " option1 " , " option2 " ] )
132141 }
133-
142+
134143 func testToAnthropicTools( ) throws {
135144 let anthropicTools = toolContainer. toAnthropicTools ( )
136-
145+
137146 XCTAssertEqual ( anthropicTools. count, 1 )
138147 XCTAssertEqual ( anthropicTools [ 0 ] . name, " testTool " )
139148 XCTAssertEqual ( anthropicTools [ 0 ] . description, " A test tool " )
@@ -154,10 +163,10 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
154163 return
155164 }
156165
157- let requiredProperties = required. compactMap { r in
158- switch r {
159- case . string( let p ) :
160- return p
166+ let requiredProperties = required. compactMap { requiredProperty in
167+ switch requiredProperty {
168+ case . string( let propertyName ) :
169+ return propertyName
161170 default :
162171 return nil
163172 }
@@ -198,24 +207,24 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
198207
199208 XCTAssertEqual ( enumValueArray. count, 2 )
200209
201- let enumValues = enumValueArray. compactMap { e in
202- switch e {
203- case . string( let v ) :
204- return v
210+ let enumValues = enumValueArray. compactMap { enumValue in
211+ switch enumValue {
212+ case . string( let value ) :
213+ return value
205214 default :
206215 return nil
207216 }
208217 }
209218 XCTAssertEqual ( enumValues, [ " option1 " , " option2 " ] )
210219 }
211-
220+
212221 func testToTogetherAITools( ) throws {
213222 let togetherAITools = toolContainer. toTogetherAITools ( )
214-
223+
215224 XCTAssertEqual ( togetherAITools. count, 1 )
216225 XCTAssertEqual ( togetherAITools [ 0 ] . function. name, " testTool " )
217226 XCTAssertEqual ( togetherAITools [ 0 ] . function. description, " A test tool " )
218-
227+
219228 // inputSchema
220229 let parameters = togetherAITools [ 0 ] . function. parameters
221230
@@ -232,10 +241,10 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
232241 return
233242 }
234243
235- let requiredProperties = required. compactMap { r in
236- switch r {
237- case . string( let p ) :
238- return p
244+ let requiredProperties = required. compactMap { requiredProperty in
245+ switch requiredProperty {
246+ case . string( let propertyName ) :
247+ return propertyName
239248 default :
240249 return nil
241250 }
@@ -276,14 +285,16 @@ final class FunctionCalling_AIProxySwiftTests: XCTestCase {
276285
277286 XCTAssertEqual ( enumValueArray. count, 2 )
278287
279- let enumValues = enumValueArray. compactMap { e in
280- switch e {
281- case . string( let v ) :
282- return v
288+ let enumValues = enumValueArray. compactMap { enumValue in
289+ switch enumValue {
290+ case . string( let value ) :
291+ return value
283292 default :
284293 return nil
285294 }
286295 }
287296 XCTAssertEqual ( enumValues, [ " option1 " , " option2 " ] )
288297 }
298+ // swiftlint:enable cyclomatic_complexity
299+ // swiftlint:enable function_body_length
289300}
0 commit comments