Minor fixes to UnitTest, Defines header

This commit is contained in:
Stephen Seo 2019-01-29 14:50:12 +09:00
parent 32e2503bd0
commit bfc704d429
5 changed files with 11 additions and 17 deletions

View file

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

View file

@ -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";

View file

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

View file

@ -172,6 +172,6 @@ int main()
*/
UDPC_Deque_destroy(deque);
UNITTEST_REPORT()
UNITTEST_REPORT(DEQUE_TEST)
return 0;
}

View file

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