Commit c149ab23 authored by louiz’'s avatar louiz’

Add a simple test for the network Command class.

parent cb077850
......@@ -138,6 +138,8 @@ file(
)
add_library(client STATIC ${source_client})
add_library(network STATIC ${source_server} ${source_client})
target_link_libraries(
client
logging
......@@ -183,9 +185,9 @@ file(
foreach(module_src ${modules_srcs})
get_filename_component(lib ${module_src} NAME_WE)
get_filename_component(lib ${module_src} NAME_WE)
string(REGEX REPLACE "(.*)_main$" "\\1" lib ${lib})
add_executable(${lib}_main EXCLUDE_FROM_ALL ${module_src})
target_link_libraries(
......@@ -204,7 +206,7 @@ file(
foreach(test_src ${tests_srcs})
get_filename_component(lib ${test_src} NAME_WE)
get_filename_component(lib ${test_src} NAME_WE)
string(REGEX REPLACE "(.*)_test$" "\\1" lib ${lib})
add_executable(${lib}_test EXCLUDE_FROM_ALL ${test_src})
......
#include <config/config.hpp>
#include <logging/logging.hpp>
#include <network/command.hpp>
#include <cstring>
#define BOOST_TEST_MODULE network
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(network_suite1)
BOOST_AUTO_TEST_CASE(command_consistency_test)
{
Command* command = new Command;
command->set_body("coucou les amis");
command->set_name("FAKE_COMMAND");
command->pack();
BOOST_REQUIRE(command->header == std::string("FAKE_COMMAND.15:"));
BOOST_REQUIRE(command->body_size == 15);
BOOST_REQUIRE(strncmp(command->body, "coucou les amis", 15) == 0);
}
BOOST_AUTO_TEST_SUITE_END()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment