From 8d9a1272b84940eb6708ddbd3b49af94d7bb7d5e Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 8 Mar 2022 12:57:26 +0100 Subject: [PATCH] move protoyping into new dir 'test' --- Makefile.conf | 2 ++ test/Makefile | 31 +++++++++++++++++--------- test/test_nr1.cc | 58 +++--------------------------------------------- 3 files changed, 25 insertions(+), 66 deletions(-) diff --git a/Makefile.conf b/Makefile.conf index de3a9f4..80c9061 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -34,3 +34,5 @@ else endif CXXFLAGS+=-I$(PREFIX)/include +LDFLAGS+=-L$(PREFIX)/lib + diff --git a/test/Makefile b/test/Makefile index b9d9fe0..2d23533 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,23 +1,32 @@ include ../Makefile.conf -LDFLAGS=-L../src -L$(PREFIX)/lib -L$(PREFIX_GTEST)/lib -LDLIBS=-lstdc++ -lpEpCxx11 -lpEpEngine -lpEpAdapter -CXXFLAGS:=-I../src $(CXXFLAGS) -I$(PREFIX_GTEST)/include +LIBC99_PATH=../examples/libc99/ +LIBC99_STATIC=$(LIBC99_PATH)libc99.a +LIBPEPDATATYPES_PATH=../src/ +LIBPEPDATATYPES_STATIC=$(LIBPEPDATATYPES_PATH)libpepdatatypes.a -TEST_SOURCE=$(wildcard *.cc) -TEST_OBJECTS=$(subst .cc,.o,$(TEST_SOURCE)) +LDLIBS=-lstdc++ -lpEpEngine -lpEpCxx11 -lpEpAdapter -lPityTest11 -lpthread -ldl -lm +CXXFLAGS:=-I$(LIBPEPDATATYPES_PATH) -I$(LIBC99_PATH) $(CXXFLAGS) -.PHONY: all, clean +# Test +SRC_TEST=$(wildcard test_*.cc) +BIN_TEST=$(subst .cc,,$(SRC_TEST)) -all: unittests +.PHONY: libc99 tests all clean -unittests: $(TEST_OBJECTS) ../src/libpEpDatatypes.a - $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) -lgtest -lgtest_main +all: libc99 tests +libc99: $(LIBC99_STATIC) +$(LIBC99_STATIC): + $(MAKE) -C ../examples/libc99 +tests: $(BIN_TEST) $(LIBC99_STATIC) + +$(BIN_TEST): $(OBJ_FRAMEWORK) clean: - rm -f unittests + rm -f $(BIN_TEST) rm -Rf *.dSYM - rm -f *.o + rm -f *.d + rm -f *.o \ No newline at end of file diff --git a/test/test_nr1.cc b/test/test_nr1.cc index 972f211..46561d6 100644 --- a/test/test_nr1.cc +++ b/test/test_nr1.cc @@ -8,7 +8,7 @@ #include #include #include - +#include "../examples/libc99/libc99.h" namespace pEp { @@ -262,12 +262,12 @@ namespace pEp { return *_c_str_pp; } - bool operator==(const pEp::String& pstr) + bool operator==(const pEp::String& pstr) const { return *(pstr.c_data()) == (*c_data()); } - bool operator!=(const pEp::String& pstr) + bool operator!=(const pEp::String& pstr) const { return !(*this == pstr); } @@ -427,58 +427,6 @@ void test_assign(char** c_str_p, pEp::String& pstr) } } -// We are testing wrappers for the c-datatypes: -// * integral e.g (int) here -// * enum -// * c-string -// * struct -// Those are all considered POD-types -extern "C" { - typedef enum - { - ONE, - TWO, - THREE - } Test_enum; - - typedef struct { - int c_int; - Test_enum c_enum; - char* c_str; - } Test_struct1; - - typedef struct { - int c_int; - Test_enum c_enum; - char* c_str; - Test_struct1* c_struct1; - } Test_struct2; - - void free_test_struct(Test_struct1* c_struct) - { - if (c_struct) { - free(c_struct->c_str); - free(c_struct); - } - } - - Test_struct1* new_test_struct(int c_int, Test_enum c_enum, const char* c_str) - { - Test_struct1* result = (Test_struct1*)calloc(1, sizeof(Test_struct1)); - if (result) { - result->c_int = c_int; - result->c_enum = c_enum; - if (c_str) { - result->c_str = strdup(c_str); - if (result->c_str == NULL) { - free_test_struct(result); - return NULL; - } - } - } - return result; - } -} namespace pEp { // TOOD: