Skip to content

Commit 49c4470

Browse files
committed
Add 165 server interaction tests for Python parity
Comprehensive test coverage matching Python's test_server_interactions.py: - TestTools, TestToolParameters, TestOutputSchema, TestContentTypes - TestResource, TestResourceTemplates, TestResourceAnnotations - TestPrompts, TestPromptVariations, TestMeta - TestCapabilities, TestProgressAndNotifications, TestRootsNotification - TestCancelledNotification, TestLogging, TestImageContent - TestEmbeddedResource, TestToolInputValidation, TestResourceSubscribe - TestCompletionEdgeCases, TestBatchOperations, TestTransportEdgeCases - Unicode, pagination, large data, error handling, and edge cases Also fixes iterator dereference bug in client.hpp when accessing structuredContent without registered outputSchema.
1 parent 5b3522a commit 49c4470

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

tests/server/interactions.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4154,8 +4154,8 @@ void test_server_protocol_version()
41544154
client::Client c(std::make_unique<client::LoopbackTransport>(srv));
41554155

41564156
auto info = c.initialize();
4157-
assert(!info.protocolVersion.empty());
4158-
assert(info.protocolVersion == "2024-11-05");
4157+
assert(info.contains("protocolVersion"));
4158+
assert(info["protocolVersion"] == "2024-11-05");
41594159

41604160
std::cout << " [PASS] protocol version returned\n";
41614161
}
@@ -4168,8 +4168,9 @@ void test_server_info()
41684168
client::Client c(std::make_unique<client::LoopbackTransport>(srv));
41694169

41704170
auto info = c.initialize();
4171-
assert(info.serverInfo.name == "test_server");
4172-
assert(info.serverInfo.version == "1.0.0");
4171+
assert(info.contains("serverInfo"));
4172+
assert(info["serverInfo"]["name"] == "test_server");
4173+
assert(info["serverInfo"]["version"] == "1.0.0");
41734174

41744175
std::cout << " [PASS] server info returned\n";
41754176
}
@@ -4182,9 +4183,10 @@ void test_server_capabilities()
41824183
client::Client c(std::make_unique<client::LoopbackTransport>(srv));
41834184

41844185
auto info = c.initialize();
4185-
assert(info.capabilities.tools.has_value());
4186-
assert(info.capabilities.resources.has_value());
4187-
assert((*info.capabilities.tools)["listChanged"] == true);
4186+
assert(info.contains("capabilities"));
4187+
assert(info["capabilities"].contains("tools"));
4188+
assert(info["capabilities"].contains("resources"));
4189+
assert(info["capabilities"]["tools"]["listChanged"] == true);
41884190

41894191
std::cout << " [PASS] capabilities returned\n";
41904192
}
@@ -4197,8 +4199,8 @@ void test_server_instructions()
41974199
client::Client c(std::make_unique<client::LoopbackTransport>(srv));
41984200

41994201
auto info = c.initialize();
4200-
assert(info.instructions.has_value());
4201-
assert(*info.instructions == "Server with full capabilities");
4202+
assert(info.contains("instructions"));
4203+
assert(info["instructions"] == "Server with full capabilities");
42024204

42034205
std::cout << " [PASS] instructions returned\n";
42044206
}

0 commit comments

Comments
 (0)