File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ endif ()
105105if (RAZ_USE_NETWORKING AND NOT RAZ_USE_EMSCRIPTEN)
106106 file (GLOB RAZ_NETWORK_TEST_FILES "${PROJECT_SOURCE_DIR} /src/RaZ/Network/*.cpp" )
107107 list (APPEND RAZ_TEST_FILES ${RAZ_NETWORK_TEST_FILES} )
108+ else ()
109+ list (REMOVE_ITEM RAZ_TEST_FILES "${PROJECT_SOURCE_DIR} /src/RaZ/Script/LuaNetwork.cpp" )
108110endif ()
109111
110112#####################
Original file line number Diff line number Diff line change 1+ #include " TestUtils.hpp"
2+
3+ #include < catch2/catch_test_macros.hpp>
4+
5+ TEST_CASE (" LuaNetwork TcpClient" , " [script][lua][network]" ) {
6+ CHECK (TestUtils::executeLuaScript (R"(
7+ local tcpClient = TcpClient.new()
8+ --tcpClient = TcpClient.new("localhost", 1234) -- Throws as there's no available server
9+
10+ --tcpClient:connect("localhost", 1234) -- Throws as there's no available server
11+ assert(not tcpClient:isConnected())
12+ -- Data transfer functions throw when not connected
13+ --tcpClient:send("data")
14+ --tcpClient:recoverAvailableByteCount()
15+ --tcpClient:receive()
16+ --tcpClient:receiveAtLeast(1)
17+ --tcpClient:receiveExactly(1)
18+ --tcpClient:receiveUntil("\0")
19+ tcpClient:disconnect()
20+ )" ));
21+ }
22+
23+ TEST_CASE (" LuaNetwork TcpServer" , " [script][lua][network]" ) {
24+ CHECK (TestUtils::executeLuaScript (R"(
25+ local tcpServer = TcpServer.new()
26+
27+ tcpServer:start(1234)
28+ tcpServer:stop()
29+ )" ));
30+ }
You can’t perform that action at this time.
0 commit comments