File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
FirebaseAI/Tests/Unit/Types Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -89,4 +89,49 @@ final class ToolTests: XCTestCase {
8989 }
9090 """ )
9191 }
92+
93+ func testEncodeTool_functionDeclarations_parametersJSONSchema( ) throws {
94+ let functionDecl = FunctionDeclaration (
95+ name: " test_function " ,
96+ description: " A test function. " ,
97+ parametersJSONSchema: [
98+ " type " : . string( " object " ) ,
99+ " properties " : . object( [
100+ " param1 " : . object( [ " type " : . string( " string " ) ] )
101+ ] ) ,
102+ " required " : . array( [ . string( " param1 " ) ] ) ,
103+ " propertyOrdering " : . array( [ . string( " param1 " ) ] ) ,
104+ " additionalProperties " : . bool( false )
105+ ]
106+ )
107+ let tool = Tool . functionDeclarations ( [ functionDecl] )
108+ let jsonData = try encoder. encode ( tool)
109+
110+ let jsonString = try XCTUnwrap ( String ( data: jsonData, encoding: . utf8) )
111+ XCTAssertEqual ( jsonString, """
112+ {
113+ " functionDeclarations " : [
114+ {
115+ " description " : " A test function. " ,
116+ " name " : " test_function " ,
117+ " parametersJsonSchema " : {
118+ " additionalProperties " : false,
119+ " properties " : {
120+ " param1 " : {
121+ " type " : " string "
122+ }
123+ },
124+ " propertyOrdering " : [
125+ " param1 "
126+ ],
127+ " required " : [
128+ " param1 "
129+ ],
130+ " type " : " object "
131+ }
132+ }
133+ ]
134+ }
135+ """ )
136+ }
92137}
You can’t perform that action at this time.
0 commit comments