diff --git a/CMakeLists.txt b/CMakeLists.txt index fbd9626..578c206 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,3 +180,12 @@ endif() if (TN_WITH_SHARED) set(THROUGHNET_LIBRARIES_SHARED throughnet_shared CACHE STRING "ThroughNet shared library") endif() + + +# ============================================================================ +# Test example +# ============================================================================ + +add_executable(example src/test/example.cc) +target_link_libraries(example throughnet) +add_test(example example) diff --git a/src/test/example.cc b/src/test/example.cc new file mode 100644 index 0000000..245ee0e --- /dev/null +++ b/src/test/example.cc @@ -0,0 +1,34 @@ +#include +#include + +#define CHECK_ERR(err, msg) { \ + if (err != 0) { \ + fprintf(stderr, "%s error: %d\n", msg, err); \ + exit(1); \ + } \ +} + + +/* =========================================================================== + * Test connect_peer1() with valid condition + */ +void connect_peer1() +{ + int err = 0; + CHECK_ERR(err, "nothing"); +} + + +/* =========================================================================== + * Usage: example + */ + +int main(int argc, char *argv[]) +{ + printf("===== Test started. =====\n"); + + connect_peer1(); + + printf("===== Test completed. =====\n"); + return 0; +}