Skip to content

Commit da9fdc9

Browse files
committed
Pretty print expected json
1 parent c7eb33e commit da9fdc9

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

FirebaseAI/Tests/Unit/Types/ToolTests.swift

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@ final class ToolTests: XCTestCase {
2222

2323
override func setUp() {
2424
super.setUp()
25-
encoder.outputFormatting = .sortedKeys
25+
encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes]
2626
}
2727

2828
func testEncodeTool_googleSearch() throws {
2929
let tool = Tool.googleSearch()
3030
let jsonData = try encoder.encode(tool)
3131
let jsonString = try XCTUnwrap(String(data: jsonData, encoding: .utf8))
32-
XCTAssertEqual(jsonString, "{\"googleSearch\":{}}")
32+
XCTAssertEqual(jsonString, """
33+
{
34+
"googleSearch" : {
35+
36+
}
37+
}
38+
""")
3339
}
3440

3541
func testEncodeTool_functionDeclarations() throws {
@@ -45,7 +51,27 @@ final class ToolTests: XCTestCase {
4551
let jsonString = try XCTUnwrap(String(data: jsonData, encoding: .utf8))
4652

4753
XCTAssertEqual(jsonString, """
48-
{"functionDeclarations":[{"description":"A test function.","name":"test_function","parameters":{"nullable":false,"properties":{"param1":{"nullable":false,"type":"STRING"}},"required":["param1"],"type":"OBJECT"}}]}
54+
{
55+
"functionDeclarations" : [
56+
{
57+
"description" : "A test function.",
58+
"name" : "test_function",
59+
"parameters" : {
60+
"nullable" : false,
61+
"properties" : {
62+
"param1" : {
63+
"nullable" : false,
64+
"type" : "STRING"
65+
}
66+
},
67+
"required" : [
68+
"param1"
69+
],
70+
"type" : "OBJECT"
71+
}
72+
}
73+
]
74+
}
4975
""")
5076
}
5177
}

0 commit comments

Comments
 (0)