| 4 | #include "fl/stl/string.h" |
| 5 | |
| 6 | FL_TEST_FILE(FL_FILEPATH) { |
| 7 | |
| 8 | using namespace fl; |
| 9 | using namespace fl::net::http; |
| 10 | |
| 11 | // Use unique high ports to avoid conflicts with other tests and services |
| 12 | static const int kBasePort = 47401; |
| 13 | |
| 14 | FL_TEST_CASE("HttpStreamServer - Construction") { |
| 15 | HttpStreamServer server(kBasePort); |
| 16 | FL_CHECK_FALSE(server.isConnected()); |
| 17 | FL_CHECK(server.getClientCount() == 0); |
| 18 | } |
| 19 | |
| 20 | FL_TEST_CASE("HttpStreamServer - Disconnect when not connected is safe") { |
| 21 | HttpStreamServer server(kBasePort + 1); |
| 22 | FL_CHECK_FALSE(server.isConnected()); |
| 23 | |
| 24 | // Should not crash |
| 25 | server.disconnect(); |
| 26 | FL_CHECK_FALSE(server.isConnected()); |
| 27 | } |
| 28 | |
| 29 | FL_TEST_CASE("HttpStreamServer - Multiple disconnects are safe") { |
| 30 | HttpStreamServer server(kBasePort + 2); |
| 31 | |
| 32 | server.disconnect(); |
| 33 | FL_CHECK_FALSE(server.isConnected()); |
| 34 | |
| 35 | server.disconnect(); |
| 36 | FL_CHECK_FALSE(server.isConnected()); |
| 37 | |
| 38 | server.disconnect(); |
| 39 | FL_CHECK_FALSE(server.isConnected()); |
| 40 | } |
| 41 | |
| 42 | FL_TEST_CASE("HttpStreamServer - getClientCount when no clients") { |
| 43 | HttpStreamServer server(kBasePort + 3); |
| 44 | FL_CHECK(server.getClientCount() == 0); |
| 45 | } |
| 46 | |
| 47 | FL_TEST_CASE("HttpStreamServer - getClientIds when no clients") { |
| 48 | HttpStreamServer server(kBasePort + 4); |
| 49 | fl::vector<uint32_t> clientIds = server.getClientIds(); |
| 50 | FL_CHECK(clientIds.empty()); |
| 51 | } |
| 52 | |
| 53 | FL_TEST_CASE("HttpStreamServer - acceptClients when not connected is safe") { |
| 54 | HttpStreamServer server(kBasePort + 5); |
| 55 | FL_CHECK_FALSE(server.isConnected()); |
| 56 | |
| 57 | // Should not crash |
| 58 | server.acceptClients(); |
| 59 | FL_CHECK(server.getClientCount() == 0); |
| 60 | } |
| 61 | |
| 62 | FL_TEST_CASE("HttpStreamServer - Write/read fail when disconnected") { |
| 63 | HttpStreamServer server(kBasePort + 6); |
nothing calls this directly
no test coverage detected