MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/stl/asio/http/http_transport.cpp:7–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include "fl/stl/json.h"
6
7FL_TEST_FILE(FL_FILEPATH) {
8
9using namespace fl;
10using namespace fl::net::http;
11
12// ============================================================================
13// Integration Tests for HTTP Transport Layer
14// ============================================================================
15// These tests verify that all HTTP transport components work together:
16// - Chunked encoding/decoding
17// - HTTP request/response parsing
18// - Connection state machine
19// - Heartbeat/keepalive
20// - Reconnection logic
21// - Error handling
22// ============================================================================
23
24// Test: Chunked Encoding Round-Trip
25FL_TEST_CASE("HTTP Transport - Chunked encoding round-trip") {
26 MockHttpServer server(47601);
27 MockHttpClient client(server);
28
29 server.connect();
30 client.connect();
31 server.update(0);
32 client.update(0);
33
34 // Send JSON-RPC request from client
35 json request = json::object();
36 request.set("jsonrpc", "2.0");
37 request.set("method", "test");
38 request.set("id", 1);
39
40 client.writeResponse(request);
41
42 // Server should receive it
43 server.update(100);
44 auto received = server.readRequest();
45 FL_REQUIRE(received.has_value());
46 FL_CHECK_EQ((*received)["method"].as_string().value(), "test");
47 FL_CHECK_EQ((*received)["id"].as_int().value(), 1);
48}
49
50// Test: Multiple Messages in Sequence
51FL_TEST_CASE("HTTP Transport - Multiple messages in sequence") {
52 MockHttpServer server(47601);
53 MockHttpClient client(server);
54
55 server.connect();
56 client.connect();
57 server.update(0);
58 client.update(0);
59
60 // Send 3 messages
61 for (int i = 0; i < 3; i++) {
62 json request = json::object();
63 request.set("jsonrpc", "2.0");
64 request.set("method", "msg");

Callers

nothing calls this directly

Calls 15

writeResponseMethod · 0.80
readRequestMethod · 0.80
setHeartbeatIntervalMethod · 0.80
getTimeoutMethod · 0.80
getHeartbeatIntervalMethod · 0.80
setOnConnectMethod · 0.80
setOnDisconnectMethod · 0.80
arrayClass · 0.50
jsonClass · 0.50
connectMethod · 0.45
updateMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected