MCPcopy Create free account
hub / github.com/ClickHouse/ai-sdk-cpp / TEST_P

Function TEST_P

tests/integration/tool_calling_integration_test.cpp:165–195  ·  view source on GitHub ↗

Test single tool calling

Source from the content-addressed store, hash-verified

163
164// Test single tool calling
165TEST_P(ToolCallingIntegrationTest, SingleToolCall) {
166 if (!use_real_api_) {
167 GTEST_SKIP() << "No API key set for " << GetParam();
168 }
169
170 GenerateOptions options(model_, "What's the weather like in San Francisco?");
171 options.tools = tools_;
172 options.max_tokens = 200;
173
174 auto result = client_->generate_text(options);
175
176 // Result should be successful, though text might be empty if only tool calls
177 // are returned
178 EXPECT_TRUE(result.is_success())
179 << "Expected successful result but got error: " << result.error_message();
180 EXPECT_FALSE(result.error.has_value())
181 << "Expected no error in successful result";
182
183 // Should have called the weather tool
184 EXPECT_TRUE(result.has_tool_calls());
185 EXPECT_GT(result.tool_calls.size(), 0);
186
187 auto weather_call = std::find_if(
188 result.tool_calls.begin(), result.tool_calls.end(),
189 [](const ToolCall& call) { return call.tool_name == "weather"; });
190 EXPECT_NE(weather_call, result.tool_calls.end());
191
192 if (weather_call != result.tool_calls.end()) {
193 EXPECT_TRUE(weather_call->arguments.contains("location"));
194 }
195}
196
197// Test multiple tool calls in one request
198TEST_P(ToolCallingIntegrationTest, MultipleDifferentToolCalls) {

Callers

nothing calls this directly

Calls 8

ToolClass · 0.85
beginMethod · 0.80
generate_textMethod · 0.45
is_successMethod · 0.45
error_messageMethod · 0.45
has_tool_callsMethod · 0.45
endMethod · 0.45
has_tool_resultsMethod · 0.45

Tested by

no test coverage detected