From 7ceabcb571c4c8be9c9b9c0d402efafa18f87696 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 28 Oct 2018 12:54:45 +0000 Subject: [PATCH 1/3] Merge from GitLab CMake-CLion feature branch --- .gitignore | 11 +++++++ CMakeLists.txt | 6 ++-- include/etl/stl/alternate/algorithm.h | 41 ++++++++++++++++++++------- test/CMakeLists.txt | 26 ++++++++++------- 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 07a9f262..ded20f8a 100644 --- a/.gitignore +++ b/.gitignore @@ -236,3 +236,14 @@ pip-log.txt *.session *.tags *.db + +############# +## CLion +############# + +.idea/ + +# CMake +cmake-build-*/ + +unittest-cpp \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c03b3bd..6cfbcd7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,12 +13,12 @@ project(etl) set(ETL_PROFILE "DEFAULT" CACHE STRING "Defines what profile header to include. See https://www.etlcpp.com/setup.html" ) -option(BUILD_TESTS "Build unit tests" ON) +option(BUILD_TESTS "Build unit tests" OFF) # Note: this will not compile src/c/ecl_timer.c as that c file has a dependence # on ecl_user.h which is provided by clients of this library -add_library(etl +add_library(etl STATIC src/binary.cpp src/crc16.cpp src/crc16_ccitt.cpp @@ -29,8 +29,6 @@ add_library(etl src/error_handler.cpp src/pearson.cpp src/random.cpp - src/private - src/private/pvoidvector.cpp ) target_include_directories(etl PUBLIC diff --git a/include/etl/stl/alternate/algorithm.h b/include/etl/stl/alternate/algorithm.h index f234b132..7bb6ebce 100644 --- a/include/etl/stl/alternate/algorithm.h +++ b/include/etl/stl/alternate/algorithm.h @@ -43,16 +43,35 @@ SOFTWARE. #if defined(ETL_IN_UNIT_TEST) #if !defined(ETLSTD) - #define ETLSTD etlstd +#define ETLSTD etlstd #endif - namespace etlstd +namespace etlstd #else #if !defined(ETLSTD) - #define ETLSTD std +#define ETLSTD std #endif - namespace std +namespace std #endif { + //*************************************************************************** + // advance + template + typename etl::enable_if::iterator_tag, ETLSTD::random_access_iterator_tag>::value, void>::type + advance(TIterator itr, TDistance distance) + { + while (distance-- != 0) + { + ++itr; + } + } + + template + typename etl::enable_if::iterator_tag, ETLSTD::random_access_iterator_tag>::value, void>::type + advance(TIterator itr, TDistance distance) + { + return itr += distance; + } + //*************************************************************************** // copy // Pointer @@ -234,7 +253,7 @@ SOFTWARE. typedef ETLSTD::less::value_type> compare; return ETLSTD::make_pair(ETLSTD::lower_bound(first, last, value, compare()), - ETLSTD::upper_bound(first, last, value, compare())); + ETLSTD::upper_bound(first, last, value, compare())); } //*************************************************************************** @@ -242,7 +261,7 @@ SOFTWARE. template TIterator find_if(TIterator first, TIterator last, TUnaryPredicate predicate) { - while (first != last) + while (first != last) { if (predicate(*first)) { @@ -302,7 +321,7 @@ SOFTWARE. { *first++ = value; } - + return first; } @@ -322,7 +341,7 @@ SOFTWARE. while (first != last) { - if (*first == value) + if (*first == value) { ++n; } @@ -342,7 +361,7 @@ SOFTWARE. while (first != last) { - if (predicate(*first)) + if (predicate(*first)) { ++n; } @@ -473,7 +492,7 @@ SOFTWARE. template TIteratorOut transform(TIteratorIn first1, TIteratorIn last1, TIteratorOut d_first, TUnaryOperation unary_operation) { - while (first1 != last1) + while (first1 != last1) { *d_first++ = unary_operation(*first1++); } @@ -572,7 +591,7 @@ SOFTWARE. value_t value = last[-1]; last[-1] = first[0]; - + private_heap::adjust_heap(first, distance_t(0), distance_t(last - first - 1), value, compare); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9ac85d7a..eea884ba 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.5.0) project(etl_unit_tests) -# Bring in the UnitTest++ include directories and libraries -find_package(UnitTest++) +add_definitions(-DETL_DEBUG) + if(NOT UnitTest++_FOUND) - # Add unittest-cpp as an ExternalProject + # Add unittest-cpp as an ExternalProject include(cmake/unit-test_external_project.cmake) add_unittest_cpp() else() @@ -46,7 +46,7 @@ set(TEST_SOURCE_FILES test_enum_type.cpp test_error_handler.cpp test_exception.cpp - test_factory.cpp +# test_factory.cpp test_fixed_iterator.cpp test_flat_map.cpp test_flat_multimap.cpp @@ -120,27 +120,31 @@ set(TEST_SOURCE_FILES test_xor_rotate_checksum.cpp # Compile the source level ecl_timer here as test has provided a ecl_user.h file - ${CMAKE_SOURCE_DIR}/src/c/ecl_timer.c + ${PROJECT_SOURCE_DIR}/../src/c/ecl_timer.c ) + + if (WIN32) # test_error_handler.cpp uses windows APIs that assume the microsoft project # is setup for unicode support. Note: This may have adverse effects on client - # projects and the tests should be updated to be independent of project setup + # projects and the tests should be updated to be independent of project setup ADD_DEFINITIONS(-DUNICODE) ADD_DEFINITIONS(-D_UNICODE) endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") list(APPEND TEST_SOURCE_FILES "test_atomic_gcc_sync.cpp") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") endif() -add_executable(etl_tests +add_executable(etl_tests ${TEST_SOURCE_FILES} ) target_link_libraries(etl_tests etl UnitTest++) target_include_directories(etl_tests - PUBLIC - ${CMAKE_CURRENT_LIST_DIR} + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} ) # Enable the 'make test' CMake target using the executable defined above @@ -152,6 +156,6 @@ add_test(etl_unit_tests etl_tests) add_custom_target(test_verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose) -# Remaining Tests to be implemented: +# Remaining Tests to be implemented: #1. Enable embedded compile target testing # - test_embedded_compile.cpp From 8cdf60124959c55701d027e2458d396f424af5b5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 28 Oct 2018 15:34:47 +0000 Subject: [PATCH 2/3] Removed unused code --- test/test_message_bus.cpp | 3 --- test/test_no_stl_algorithm.cpp | 16 ++++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/test/test_message_bus.cpp b/test/test_message_bus.cpp index 2bf23e94..483a914e 100644 --- a/test/test_message_bus.cpp +++ b/test/test_message_bus.cpp @@ -205,9 +205,6 @@ namespace int message_unknown_count; }; - etl::imessage_router* p_router; - etl::imessage_bus* p_bus; - SUITE(test_message_router) { //========================================================================= diff --git a/test/test_no_stl_algorithm.cpp b/test/test_no_stl_algorithm.cpp index 36c75673..a41096d2 100644 --- a/test/test_no_stl_algorithm.cpp +++ b/test/test_no_stl_algorithm.cpp @@ -103,11 +103,11 @@ namespace } }; - std::ostream& operator << (std::ostream& os, const Data& data_) - { - os << data_.a << "," << data_.b; - return os; - } +// std::ostream& operator << (std::ostream& os, const Data& data_) +// { +// os << data_.a << "," << data_.b; +// return os; +// } struct Greater : public std::binary_function { @@ -383,7 +383,7 @@ namespace int b = 2; etlstd::swap(a, b); - CHECK_EQUAL(2, a); + CHECK_EQUAL(2, a); CHECK_EQUAL(1, b); } @@ -437,7 +437,7 @@ namespace std::string::iterator itr1 = std::search(haystack.begin(), haystack.end(), needle.begin(), needle.begin()); std::string::iterator itr2 = etlstd::search(haystack.begin(), haystack.end(), needle.begin(), needle.begin()); - + CHECK(itr1 == itr2); } @@ -493,7 +493,7 @@ namespace etlstd::push_heap(data2.begin(), data2.end()); CHECK(std::is_heap(data2.begin(), data2.end())); - + isEqual = std::equal(std::begin(data1), std::end(data1), std::begin(data2)); CHECK(isEqual); } From 3cb35ffd7c75c9aeefa600a0621f7afa63169494 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 4 Nov 2018 10:10:50 +0000 Subject: [PATCH 3/3] Trigger CI pipelines on gitlab --- .gitlab-ci.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..580aa237 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,24 @@ +image: rikorose/gcc-cmake + +variables: + GIT_SUBMODULE_STRATEGY: recursive + GIT_STRATEGY: clone + +stages: + - build + - test + +Build ETL: + stage: build + script: + - cmake -DBUILD_TESTS=ON ./ + - make + artifacts: + paths: + - ./test/etl_tests + +Run ETL tests: + stage: test + dependencies: + - Build ETL + script: ./test/etl_tests \ No newline at end of file