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

Function TEST_F

tests/integration/openai_embeddings_integration_test.cpp:65–90  ·  view source on GitHub ↗

Basic Embeddings Tests

Source from the content-addressed store, hash-verified

63
64// Basic Embeddings Tests
65TEST_F(OpenAIEmbeddingsIntegrationTest, BasicSingleStringEmbedding) {
66 if (!use_real_api_) {
67 GTEST_SKIP() << "No OPENAI_API_KEY environment variable set";
68 }
69
70 nlohmann::json input = "Hello, world!";
71 EmbeddingOptions options("text-embedding-3-small", input);
72 auto result = client_->embeddings(options);
73
74 ASSERT_TRUE(result.is_success()) << "Error: " << result.error_message();
75 EXPECT_FALSE(result.data.is_null());
76 EXPECT_TRUE(result.data.is_array());
77 EXPECT_EQ(result.data.size(), 1);
78
79 // Check that we got an embedding vector
80 auto embedding = result.data[0]["embedding"];
81 EXPECT_TRUE(embedding.is_array());
82 EXPECT_GT(embedding.size(), 0);
83
84 // text-embedding-3-small should have 1536 dimensions by default
85 EXPECT_EQ(embedding.size(), 1536);
86
87 // Check token usage
88 EXPECT_GT(result.usage.total_tokens, 0);
89 EXPECT_GT(result.usage.prompt_tokens, 0);
90}
91
92TEST_F(OpenAIEmbeddingsIntegrationTest, MultipleStringsEmbedding) {
93 if (!use_real_api_) {

Callers

nothing calls this directly

Calls 5

cosine_similarityFunction · 0.85
create_clientFunction · 0.50
embeddingsMethod · 0.45
is_successMethod · 0.45
error_messageMethod · 0.45

Tested by

no test coverage detected