| 5 | #include "fl/stl/json.h" |
| 6 | |
| 7 | FL_TEST_FILE(FL_FILEPATH) { |
| 8 | |
| 9 | using namespace fl; |
| 10 | using namespace fl::net::http; |
| 11 | |
| 12 | // Test: MockHttpServer - Construction |
| 13 | FL_TEST_CASE("MockHttpServer - Construction") { |
| 14 | MockHttpServer server(47701); |
| 15 | FL_CHECK_FALSE(server.isConnected()); |
| 16 | FL_CHECK_EQ(0, server.getClientCount()); |
| 17 | } |
| 18 | |
| 19 | // Test: MockHttpServer - Start |
| 20 | FL_TEST_CASE("MockHttpServer - Start server") { |
| 21 | MockHttpServer server(47701); |
| 22 | FL_CHECK(server.connect()); |
| 23 | FL_CHECK(server.isConnected()); |
| 24 | } |
| 25 | |
| 26 | // Test: MockHttpServer - Stop |
| 27 | FL_TEST_CASE("MockHttpServer - Stop server") { |
| 28 | MockHttpServer server(47701); |
| 29 | server.connect(); |
| 30 | server.disconnect(); |
| 31 | FL_CHECK_FALSE(server.isConnected()); |
| 32 | } |
| 33 | |
| 34 | // Test: MockHttpServer - Double start is safe |
| 35 | FL_TEST_CASE("MockHttpServer - Double start is safe") { |
| 36 | MockHttpServer server(47701); |
| 37 | FL_CHECK(server.connect()); |
| 38 | FL_CHECK(server.connect()); |
| 39 | FL_CHECK(server.isConnected()); |
| 40 | } |
| 41 | |
| 42 | // Test: MockHttpServer - Double stop is safe |
| 43 | FL_TEST_CASE("MockHttpServer - Double stop is safe") { |
| 44 | MockHttpServer server(47701); |
| 45 | server.connect(); |
| 46 | server.disconnect(); |
| 47 | server.disconnect(); |
| 48 | FL_CHECK_FALSE(server.isConnected()); |
| 49 | } |
| 50 | |
| 51 | // Test: MockHttpServer - Accept single client |
| 52 | FL_TEST_CASE("MockHttpServer - Accept single client") { |
| 53 | MockHttpServer server(47701); |
| 54 | server.connect(); |
| 55 | |
| 56 | uint32_t clientId = server.acceptClient(); |
| 57 | FL_CHECK_NE(0, clientId); |
| 58 | FL_CHECK_EQ(1, server.getClientCount()); |
| 59 | } |
| 60 | |
| 61 | // Test: MockHttpServer - Accept multiple clients |
| 62 | FL_TEST_CASE("MockHttpServer - Accept multiple clients") { |
| 63 | MockHttpServer server(47701); |
| 64 | server.connect(); |
nothing calls this directly
no test coverage detected