Skip to content

Commit 754c476

Browse files
committed
add tests
1 parent efd280e commit 754c476

File tree

2 files changed

+56
-6
lines changed

2 files changed

+56
-6
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// Extensions.swift
3+
// FunctionCalling-FirebaseVertexAI
4+
//
5+
// Created by 伊藤史 on 2024/09/20.
6+
//
7+
8+
@testable import FirebaseVertexAI
9+
10+
extension FirebaseVertexAI.Tool {
11+
var functions: [FirebaseVertexAI.FunctionDeclaration]? {
12+
functionDeclarations
13+
}
14+
}
15+
16+
extension FirebaseVertexAI.FunctionDeclaration {
17+
func getName() -> String {
18+
name
19+
}
20+
21+
func getDescription() -> String {
22+
description
23+
}
24+
}
Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
11
import XCTest
22
@testable import FunctionCalling_FirebaseVertexAI
3+
import FunctionCalling
34

45
final class FunctionCalling_FirebaseVertexAITests: XCTestCase {
5-
func testExample() throws {
6-
// XCTest Documentation
7-
// https://developer.apple.com/documentation/xctest
6+
@FunctionCalling(service: .claude)
7+
struct FunctionContainer {
8+
/// Return current weather of location that passed by the argument
9+
/// - Parameter location: location that I want to know how the weather
10+
/// - Returns: string of weather
11+
@CallableFunction
12+
func getWeather(location: String) -> String {
13+
return "Sunny"
14+
}
815

9-
// Defining Test Cases and Test Methods
10-
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods
11-
}
16+
@CallableFunction
17+
func getStock(args: String) -> Int {
18+
return 0
19+
}
20+
}
21+
22+
func testConvertedResults() throws {
23+
guard let functions = FunctionContainer().firebaseVertexAITools.first?.functions else {
24+
XCTFail("Conainer should contain some functions")
25+
return
26+
}
27+
28+
XCTAssertEqual(functions.count, 2)
29+
30+
let getWeather = try XCTUnwrap(functions.first)
31+
XCTAssertEqual(getWeather.getName(), "getWeather")
32+
XCTAssertEqual(getWeather.getDescription(), "Return current weather of location that passed by the argument- Parameter location: location that I want to know how the weather- Returns: string of weather")
33+
34+
let getStock = try XCTUnwrap(functions.last)
35+
XCTAssertEqual(getStock.getName(), "getStock")
36+
XCTAssertEqual(getStock.getDescription(), "")
37+
}
1238
}

0 commit comments

Comments
 (0)