Add test example

master
Ryan Lee 2016-03-02 20:39:40 +09:00
parent 6066e95f01
commit d592dbb4f7
2 changed files with 43 additions and 0 deletions

View File

@ -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)

34
src/test/example.cc Normal file
View File

@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
#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;
}