From bfc704d42982ffd10f1f0888d7322c03352572e0 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 29 Jan 2019 14:50:12 +0900 Subject: [PATCH] Minor fixes to UnitTest, Defines header --- CMakeLists.txt | 1 - src/UDPC_Defines.c | 8 -------- src/UDPC_Defines.h | 12 ++++++------ src/test/UDPC_UnitTest.c | 2 +- src/test/UDPC_UnitTest.h | 5 ++++- 5 files changed, 11 insertions(+), 17 deletions(-) delete mode 100644 src/UDPC_Defines.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b9a66b..e15e0b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,6 @@ project(UDPConnection) set(UDPConnection_SOURCES src/UDPConnection.c src/UDPC_Deque.c - src/UDPC_Defines.c ) set(CMAKE_C_FLAGS "-Wall -Wno-missing-braces") diff --git a/src/UDPC_Defines.c b/src/UDPC_Defines.c deleted file mode 100644 index e6c82cb..0000000 --- a/src/UDPC_Defines.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "UDPC_Defines.h" - -static const char *UDPC_ERR_SOCKETFAIL_STR = "Failed to create socket"; -static const char *UDPC_ERR_SOCKETBINDF_STR = "Failed to bind socket"; -static const char *UDPC_ERR_SOCKETNONBF_STR = "Failed to set non-blocking on socket"; -static const char *UDPC_ERR_MTXFAIL_STR = "Failed to create mutex"; -static const char *UDPC_ERR_CVFAIL_STR = "Failed to create condition variable"; -static const char *UDPC_ERR_THREADFAIL_STR = "Failed to create thread"; diff --git a/src/UDPC_Defines.h b/src/UDPC_Defines.h index d2cfa7d..83c1b30 100644 --- a/src/UDPC_Defines.h +++ b/src/UDPC_Defines.h @@ -24,11 +24,11 @@ #define UDPC_ERR_CVFAIL 5 // failed to create condition variable #define UDPC_ERR_THREADFAIL 6 // failed to create thread -static const char *UDPC_ERR_SOCKETFAIL_STR; -static const char *UDPC_ERR_SOCKETBINDF_STR; -static const char *UDPC_ERR_SOCKETNONBF_STR; -static const char *UDPC_ERR_MTXFAIL_STR; -static const char *UDPC_ERR_CVFAIL_STR; -static const char *UDPC_ERR_THREADFAIL_STR; +static const char *UDPC_ERR_SOCKETFAIL_STR = "Failed to create socket"; +static const char *UDPC_ERR_SOCKETBINDF_STR = "Failed to bind socket"; +static const char *UDPC_ERR_SOCKETNONBF_STR = "Failed to set non-blocking on socket"; +static const char *UDPC_ERR_MTXFAIL_STR = "Failed to create mutex"; +static const char *UDPC_ERR_CVFAIL_STR = "Failed to create condition variable"; +static const char *UDPC_ERR_THREADFAIL_STR = "Failed to create thread"; #endif diff --git a/src/test/UDPC_UnitTest.c b/src/test/UDPC_UnitTest.c index 2090dc6..1e0d173 100644 --- a/src/test/UDPC_UnitTest.c +++ b/src/test/UDPC_UnitTest.c @@ -172,6 +172,6 @@ int main() */ UDPC_Deque_destroy(deque); - UNITTEST_REPORT() + UNITTEST_REPORT(DEQUE_TEST) return 0; } diff --git a/src/test/UDPC_UnitTest.h b/src/test/UDPC_UnitTest.h index 83e4032..b98950c 100644 --- a/src/test/UDPC_UnitTest.h +++ b/src/test/UDPC_UnitTest.h @@ -27,7 +27,10 @@ if(memcmp(x, y, size) == 0) { printf("%d: ASSERT_NEQ_MEM(%s, %s, %s) FAILED\n", \ __LINE__, #x, #y, #size); ++UDPC_uts.failed; } ++UDPC_uts.total; -#define UNITTEST_REPORT() printf("%d/%d tests failed\n", UDPC_uts.failed, UDPC_uts.total); +#define UNITTEST_REPORT(x) { \ + printf("%s: %d/%d tests failed\n", #x, UDPC_uts.failed, UDPC_uts.total); \ + UDPC_uts.failed = 0; \ + UDPC_uts.total = 0; } typedef struct