From 92cf6fa66dd54ec4e0096f39ba1577c566f77cf0 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Thu, 11 Feb 2016 12:04:49 +0100 Subject: [PATCH] Refactor directory layout to allow other modules in same repository --- CMakeLists.txt | 2 + src/CMakeLists.txt | 102 +----------------- src/cpp-utils/CMakeLists.txt | 53 +++++++++ src/{ => cpp-utils}/assert/AssertFailed.cpp | 0 src/{ => cpp-utils}/assert/AssertFailed.h | 0 src/{ => cpp-utils}/assert/assert.h | 0 src/{ => cpp-utils}/assert/backtrace.cpp | 0 src/{ => cpp-utils}/assert/backtrace.h | 0 src/{ => cpp-utils}/crypto/RandomPadding.cpp | 0 src/{ => cpp-utils}/crypto/RandomPadding.h | 0 src/{ => cpp-utils}/crypto/kdf/DerivedKey.cpp | 0 src/{ => cpp-utils}/crypto/kdf/DerivedKey.h | 0 .../crypto/kdf/DerivedKeyConfig.cpp | 0 .../crypto/kdf/DerivedKeyConfig.h | 0 src/{ => cpp-utils}/crypto/kdf/Scrypt.cpp | 0 src/{ => cpp-utils}/crypto/kdf/Scrypt.h | 2 +- .../crypto/symmetric/CFB_Cipher.h | 0 src/{ => cpp-utils}/crypto/symmetric/Cipher.h | 0 .../crypto/symmetric/GCM_Cipher.h | 0 .../crypto/symmetric/ciphers.cpp | 0 .../crypto/symmetric/ciphers.h | 0 src/{ => cpp-utils}/data/Data.cpp | 0 src/{ => cpp-utils}/data/Data.h | 0 src/{ => cpp-utils}/data/DataFixture.cpp | 0 src/{ => cpp-utils}/data/DataFixture.h | 0 src/{ => cpp-utils}/data/DataUtils.cpp | 0 src/{ => cpp-utils}/data/DataUtils.h | 0 src/{ => cpp-utils}/data/Deserializer.cpp | 0 src/{ => cpp-utils}/data/Deserializer.h | 0 src/{ => cpp-utils}/data/FixedSizeData.h | 0 src/{ => cpp-utils}/data/Serializer.cpp | 0 src/{ => cpp-utils}/data/Serializer.h | 0 src/{ => cpp-utils}/either.h | 0 src/{ => cpp-utils}/io/Console.cpp | 0 src/{ => cpp-utils}/io/Console.h | 0 src/{ => cpp-utils}/io/pipestream.cpp | 0 src/{ => cpp-utils}/io/pipestream.h | 0 src/{ => cpp-utils}/lock/ConditionBarrier.h | 0 src/{ => cpp-utils}/lock/LockPool.cpp | 0 src/{ => cpp-utils}/lock/LockPool.h | 0 src/{ => cpp-utils}/lock/MutexPoolLock.h | 0 src/{ => cpp-utils}/logging/Logger.h | 2 +- src/{ => cpp-utils}/logging/logging.h | 0 src/{ => cpp-utils}/macros.h | 0 .../network/CurlHttpClient.cpp | 0 src/{ => cpp-utils}/network/CurlHttpClient.h | 0 .../network/FakeHttpClient.cpp | 0 src/{ => cpp-utils}/network/FakeHttpClient.h | 0 src/{ => cpp-utils}/network/HttpClient.cpp | 0 src/{ => cpp-utils}/network/HttpClient.h | 0 src/{ => cpp-utils}/pointer/cast.h | 0 .../pointer/gcc_4_8_compatibility.h | 0 .../pointer/optional_ownership_ptr.h | 0 src/{ => cpp-utils}/pointer/unique_ref.h | 0 ...ique_ref_boost_optional_gtest_workaround.h | 0 src/{ => cpp-utils}/process/daemonize.cpp | 0 src/{ => cpp-utils}/process/daemonize.h | 0 src/{ => cpp-utils}/process/subprocess.cpp | 0 src/{ => cpp-utils}/process/subprocess.h | 0 .../random/OSRandomGenerator.cpp | 0 .../random/OSRandomGenerator.h | 0 .../random/PseudoRandomPool.cpp | 0 src/{ => cpp-utils}/random/PseudoRandomPool.h | 0 src/{ => cpp-utils}/random/Random.cpp | 0 src/{ => cpp-utils}/random/Random.h | 0 .../random/RandomDataBuffer.cpp | 0 src/{ => cpp-utils}/random/RandomDataBuffer.h | 0 .../random/RandomGenerator.cpp | 0 src/{ => cpp-utils}/random/RandomGenerator.h | 0 .../random/RandomGeneratorThread.cpp | 0 .../random/RandomGeneratorThread.h | 0 .../random/ThreadsafeRandomDataBuffer.h | 0 src/{ => cpp-utils}/tempfile/TempDir.cpp | 0 src/{ => cpp-utils}/tempfile/TempDir.h | 0 src/{ => cpp-utils}/tempfile/TempFile.cpp | 0 src/{ => cpp-utils}/tempfile/TempFile.h | 0 src/{ => cpp-utils}/thread/LoopThread.cpp | 0 src/{ => cpp-utils}/thread/LoopThread.h | 0 src/{ => cpp-utils}/thread/ThreadSystem.cpp | 0 src/{ => cpp-utils}/thread/ThreadSystem.h | 0 test/CMakeLists.txt | 61 +---------- test/cpp-utils/CMakeLists.txt | 57 ++++++++++ test/{ => cpp-utils}/EitherIncludeTest.cpp | 2 +- test/{ => cpp-utils}/EitherTest.cpp | 4 +- test/{ => cpp-utils}/MacrosIncludeTest.cpp | 2 +- .../assert/assert_debug_test.cpp | 2 +- .../assert/assert_include_test.cpp | 2 +- .../assert/assert_release_test.cpp | 2 +- .../assert/backtrace_include_test.cpp | 2 +- .../crypto/kdf/DerivedKeyConfigTest.cpp | 22 ++-- .../crypto/kdf/DerivedKeyTest.cpp | 10 +- .../{ => cpp-utils}/crypto/kdf/SCryptTest.cpp | 2 +- .../crypto/symmetric/CipherTest.cpp | 8 +- .../testutils/FakeAuthenticatedCipher.cpp | 0 .../testutils/FakeAuthenticatedCipher.h | 8 +- .../data/DataFixtureIncludeTest.cpp | 2 +- test/{ => cpp-utils}/data/DataFixtureTest.cpp | 10 +- test/{ => cpp-utils}/data/DataIncludeTest.cpp | 2 +- test/{ => cpp-utils}/data/DataTest.cpp | 10 +- .../data/FixedSizeDataIncludeTest.cpp | 2 +- .../data/FixedSizeDataTest.cpp | 6 +- .../{ => cpp-utils}/io/ConsoleIncludeTest.cpp | 2 +- test/{ => cpp-utils}/io/ConsoleTest.h | 4 +- test/{ => cpp-utils}/io/ConsoleTest_Ask.cpp | 24 ++--- .../io/ConsoleTest_AskYesNo.cpp | 0 test/{ => cpp-utils}/io/ConsoleTest_Print.cpp | 0 .../lock/ConditionBarrierIncludeTest.cpp | 2 +- .../lock/LockPoolIncludeTest.cpp | 2 +- .../lock/MutexPoolLockIncludeTest.cpp | 2 +- .../logging/LoggerIncludeTest.cpp | 2 +- test/{ => cpp-utils}/logging/LoggerTest.cpp | 0 .../logging/LoggingIncludeTest.cpp | 2 +- .../logging/LoggingLevelTest.cpp | 0 test/{ => cpp-utils}/logging/LoggingTest.cpp | 0 .../logging/testutils/LoggingTest.h | 2 +- .../network/CurlHttpClientTest.cpp | 4 +- .../network/FakeHttpClientTest.cpp | 4 +- .../pointer/cast_include_test.cpp | 2 +- test/{ => cpp-utils}/pointer/cast_test.cpp | 6 +- .../optional_ownership_ptr_include_test.cpp | 2 +- .../pointer/optional_ownership_ptr_test.cpp | 4 +- ...optional_gtest_workaround_include_test.cpp | 3 + .../pointer/unique_ref_include_test.cpp | 2 +- .../pointer/unique_ref_test.cpp | 2 +- .../process/daemonize_include_test.cpp | 2 +- .../process/subprocess_include_test.cpp | 2 +- .../random/RandomIncludeTest.cpp | 2 +- .../tempfile/TempDirIncludeTest.cpp | 2 +- test/{ => cpp-utils}/tempfile/TempDirTest.cpp | 2 +- .../tempfile/TempFileIncludeTest.cpp | 2 +- .../{ => cpp-utils}/tempfile/TempFileTest.cpp | 4 +- ...optional_gtest_workaround_include_test.cpp | 3 - utils.cmake | 47 ++++++++ 133 files changed, 259 insertions(+), 255 deletions(-) create mode 100644 src/cpp-utils/CMakeLists.txt rename src/{ => cpp-utils}/assert/AssertFailed.cpp (100%) rename src/{ => cpp-utils}/assert/AssertFailed.h (100%) rename src/{ => cpp-utils}/assert/assert.h (100%) rename src/{ => cpp-utils}/assert/backtrace.cpp (100%) rename src/{ => cpp-utils}/assert/backtrace.h (100%) rename src/{ => cpp-utils}/crypto/RandomPadding.cpp (100%) rename src/{ => cpp-utils}/crypto/RandomPadding.h (100%) rename src/{ => cpp-utils}/crypto/kdf/DerivedKey.cpp (100%) rename src/{ => cpp-utils}/crypto/kdf/DerivedKey.h (100%) rename src/{ => cpp-utils}/crypto/kdf/DerivedKeyConfig.cpp (100%) rename src/{ => cpp-utils}/crypto/kdf/DerivedKeyConfig.h (100%) rename src/{ => cpp-utils}/crypto/kdf/Scrypt.cpp (100%) rename src/{ => cpp-utils}/crypto/kdf/Scrypt.h (96%) rename src/{ => cpp-utils}/crypto/symmetric/CFB_Cipher.h (100%) rename src/{ => cpp-utils}/crypto/symmetric/Cipher.h (100%) rename src/{ => cpp-utils}/crypto/symmetric/GCM_Cipher.h (100%) rename src/{ => cpp-utils}/crypto/symmetric/ciphers.cpp (100%) rename src/{ => cpp-utils}/crypto/symmetric/ciphers.h (100%) rename src/{ => cpp-utils}/data/Data.cpp (100%) rename src/{ => cpp-utils}/data/Data.h (100%) rename src/{ => cpp-utils}/data/DataFixture.cpp (100%) rename src/{ => cpp-utils}/data/DataFixture.h (100%) rename src/{ => cpp-utils}/data/DataUtils.cpp (100%) rename src/{ => cpp-utils}/data/DataUtils.h (100%) rename src/{ => cpp-utils}/data/Deserializer.cpp (100%) rename src/{ => cpp-utils}/data/Deserializer.h (100%) rename src/{ => cpp-utils}/data/FixedSizeData.h (100%) rename src/{ => cpp-utils}/data/Serializer.cpp (100%) rename src/{ => cpp-utils}/data/Serializer.h (100%) rename src/{ => cpp-utils}/either.h (100%) rename src/{ => cpp-utils}/io/Console.cpp (100%) rename src/{ => cpp-utils}/io/Console.h (100%) rename src/{ => cpp-utils}/io/pipestream.cpp (100%) rename src/{ => cpp-utils}/io/pipestream.h (100%) rename src/{ => cpp-utils}/lock/ConditionBarrier.h (100%) rename src/{ => cpp-utils}/lock/LockPool.cpp (100%) rename src/{ => cpp-utils}/lock/LockPool.h (100%) rename src/{ => cpp-utils}/lock/MutexPoolLock.h (100%) rename src/{ => cpp-utils}/logging/Logger.h (96%) rename src/{ => cpp-utils}/logging/logging.h (100%) rename src/{ => cpp-utils}/macros.h (100%) rename src/{ => cpp-utils}/network/CurlHttpClient.cpp (100%) rename src/{ => cpp-utils}/network/CurlHttpClient.h (100%) rename src/{ => cpp-utils}/network/FakeHttpClient.cpp (100%) rename src/{ => cpp-utils}/network/FakeHttpClient.h (100%) rename src/{ => cpp-utils}/network/HttpClient.cpp (100%) rename src/{ => cpp-utils}/network/HttpClient.h (100%) rename src/{ => cpp-utils}/pointer/cast.h (100%) rename src/{ => cpp-utils}/pointer/gcc_4_8_compatibility.h (100%) rename src/{ => cpp-utils}/pointer/optional_ownership_ptr.h (100%) rename src/{ => cpp-utils}/pointer/unique_ref.h (100%) rename src/{ => cpp-utils}/pointer/unique_ref_boost_optional_gtest_workaround.h (100%) rename src/{ => cpp-utils}/process/daemonize.cpp (100%) rename src/{ => cpp-utils}/process/daemonize.h (100%) rename src/{ => cpp-utils}/process/subprocess.cpp (100%) rename src/{ => cpp-utils}/process/subprocess.h (100%) rename src/{ => cpp-utils}/random/OSRandomGenerator.cpp (100%) rename src/{ => cpp-utils}/random/OSRandomGenerator.h (100%) rename src/{ => cpp-utils}/random/PseudoRandomPool.cpp (100%) rename src/{ => cpp-utils}/random/PseudoRandomPool.h (100%) rename src/{ => cpp-utils}/random/Random.cpp (100%) rename src/{ => cpp-utils}/random/Random.h (100%) rename src/{ => cpp-utils}/random/RandomDataBuffer.cpp (100%) rename src/{ => cpp-utils}/random/RandomDataBuffer.h (100%) rename src/{ => cpp-utils}/random/RandomGenerator.cpp (100%) rename src/{ => cpp-utils}/random/RandomGenerator.h (100%) rename src/{ => cpp-utils}/random/RandomGeneratorThread.cpp (100%) rename src/{ => cpp-utils}/random/RandomGeneratorThread.h (100%) rename src/{ => cpp-utils}/random/ThreadsafeRandomDataBuffer.h (100%) rename src/{ => cpp-utils}/tempfile/TempDir.cpp (100%) rename src/{ => cpp-utils}/tempfile/TempDir.h (100%) rename src/{ => cpp-utils}/tempfile/TempFile.cpp (100%) rename src/{ => cpp-utils}/tempfile/TempFile.h (100%) rename src/{ => cpp-utils}/thread/LoopThread.cpp (100%) rename src/{ => cpp-utils}/thread/LoopThread.h (100%) rename src/{ => cpp-utils}/thread/ThreadSystem.cpp (100%) rename src/{ => cpp-utils}/thread/ThreadSystem.h (100%) create mode 100644 test/cpp-utils/CMakeLists.txt rename test/{ => cpp-utils}/EitherIncludeTest.cpp (65%) rename test/{ => cpp-utils}/EitherTest.cpp (99%) rename test/{ => cpp-utils}/MacrosIncludeTest.cpp (66%) rename test/{ => cpp-utils}/assert/assert_debug_test.cpp (91%) rename test/{ => cpp-utils}/assert/assert_include_test.cpp (60%) rename test/{ => cpp-utils}/assert/assert_release_test.cpp (92%) rename test/{ => cpp-utils}/assert/backtrace_include_test.cpp (59%) rename test/{ => cpp-utils}/crypto/kdf/DerivedKeyConfigTest.cpp (84%) rename test/{ => cpp-utils}/crypto/kdf/DerivedKeyTest.cpp (68%) rename test/{ => cpp-utils}/crypto/kdf/SCryptTest.cpp (97%) rename test/{ => cpp-utils}/crypto/symmetric/CipherTest.cpp (97%) rename test/{ => cpp-utils}/crypto/symmetric/testutils/FakeAuthenticatedCipher.cpp (100%) rename test/{ => cpp-utils}/crypto/symmetric/testutils/FakeAuthenticatedCipher.h (93%) rename test/{ => cpp-utils}/data/DataFixtureIncludeTest.cpp (50%) rename test/{ => cpp-utils}/data/DataFixtureTest.cpp (91%) rename test/{ => cpp-utils}/data/DataIncludeTest.cpp (53%) rename test/{ => cpp-utils}/data/DataTest.cpp (96%) rename test/{ => cpp-utils}/data/FixedSizeDataIncludeTest.cpp (50%) rename test/{ => cpp-utils}/data/FixedSizeDataTest.cpp (97%) rename test/{ => cpp-utils}/io/ConsoleIncludeTest.cpp (61%) rename test/{ => cpp-utils}/io/ConsoleTest.h (95%) rename test/{ => cpp-utils}/io/ConsoleTest_Ask.cpp (93%) rename test/{ => cpp-utils}/io/ConsoleTest_AskYesNo.cpp (100%) rename test/{ => cpp-utils}/io/ConsoleTest_Print.cpp (100%) rename test/{ => cpp-utils}/lock/ConditionBarrierIncludeTest.cpp (56%) rename test/{ => cpp-utils}/lock/LockPoolIncludeTest.cpp (60%) rename test/{ => cpp-utils}/lock/MutexPoolLockIncludeTest.cpp (58%) rename test/{ => cpp-utils}/logging/LoggerIncludeTest.cpp (59%) rename test/{ => cpp-utils}/logging/LoggerTest.cpp (100%) rename test/{ => cpp-utils}/logging/LoggingIncludeTest.cpp (59%) rename test/{ => cpp-utils}/logging/LoggingLevelTest.cpp (100%) rename test/{ => cpp-utils}/logging/LoggingTest.cpp (100%) rename test/{ => cpp-utils}/logging/testutils/LoggingTest.h (95%) rename test/{ => cpp-utils}/network/CurlHttpClientTest.cpp (85%) rename test/{ => cpp-utils}/network/FakeHttpClientTest.cpp (89%) rename test/{ => cpp-utils}/pointer/cast_include_test.cpp (60%) rename test/{ => cpp-utils}/pointer/cast_test.cpp (97%) rename test/{ => cpp-utils}/pointer/optional_ownership_ptr_include_test.cpp (53%) rename test/{ => cpp-utils}/pointer/optional_ownership_ptr_test.cpp (96%) create mode 100644 test/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp rename test/{ => cpp-utils}/pointer/unique_ref_include_test.cpp (58%) rename test/{ => cpp-utils}/pointer/unique_ref_test.cpp (99%) rename test/{ => cpp-utils}/process/daemonize_include_test.cpp (58%) rename test/{ => cpp-utils}/process/subprocess_include_test.cpp (58%) rename test/{ => cpp-utils}/random/RandomIncludeTest.cpp (60%) rename test/{ => cpp-utils}/tempfile/TempDirIncludeTest.cpp (58%) rename test/{ => cpp-utils}/tempfile/TempDirTest.cpp (95%) rename test/{ => cpp-utils}/tempfile/TempFileIncludeTest.cpp (58%) rename test/{ => cpp-utils}/tempfile/TempFileTest.cpp (96%) delete mode 100644 test/pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp create mode 100644 utils.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 455e1afa..81e07aae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.0) +include(utils.cmake) + add_subdirectory(vendor) add_subdirectory(src) add_subdirectory(test) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d2f1048..7b60f025 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,101 +1 @@ -include(CheckCXXCompilerFlag) - -################################################### -# Activate C++14 -# -# Uses: ACTIVATE_CPP14() -################################################### -macro(ACTIVATE_CPP14) - CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_HAS_CPP14_SUPPORT) - IF (COMPILER_HAS_CPP14_SUPPORT) - TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PUBLIC -std=c++14) - ELSE() - CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_HAS_CPP14_PARTIAL_SUPPORT) - IF (COMPILER_HAS_CPP14_PARTIAL_SUPPORT) - TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PUBLIC -std=c++1y) - ELSE() - MESSAGE(FATAL_ERROR "Compiler doesn't support C++14") - ENDIF() - ENDIF() - IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PUBLIC -stdlib=libc++) - ENDIF() -endmacro(ACTIVATE_CPP14) - -################################################# -# Enable style compiler warnings -################################################# -macro(ENABLE_STYLE_WARNINGS) -# TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE -Wall -Wextra -Weffc++) - TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PRIVATE -Wall -Wextra) -endmacro(ENABLE_STYLE_WARNINGS) - -################################################## -# Add boost to the project -# -# Uses: -# ADD_BOOST() # if you're only using header-only boost libs -# ADD_BOOST(system filesystem) # list all libraries to link against in the dependencies -################################################## -function(ADD_BOOST) - # Load boost libraries - find_package(Boost 1.56.0 - REQUIRED - COMPONENTS ${ARGN}) - set(Boost_USE_STATIC_LIBS ON) - target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${Boost_INCLUDE_DIRS}) - target_link_libraries(${PROJECT_NAME} PRIVATE ${Boost_LIBRARIES}) -endfunction() - -cmake_minimum_required(VERSION 3.0) -project (cpp-utils) - -set(SOURCES - crypto/symmetric/ciphers.cpp - crypto/kdf/DerivedKey.cpp - crypto/kdf/Scrypt.cpp - crypto/kdf/DerivedKeyConfig.cpp - crypto/RandomPadding.cpp - process/daemonize.cpp - process/subprocess.cpp - tempfile/TempFile.cpp - tempfile/TempDir.cpp - network/HttpClient.cpp - network/CurlHttpClient.cpp - network/FakeHttpClient.cpp - io/Console.cpp - io/pipestream.cpp - thread/LoopThread.cpp - thread/ThreadSystem.cpp - random/Random.cpp - random/RandomGeneratorThread.cpp - random/OSRandomGenerator.cpp - random/PseudoRandomPool.cpp - random/RandomDataBuffer.cpp - random/RandomGenerator.cpp - lock/LockPool.cpp - data/Serializer.cpp - data/Deserializer.cpp - data/DataFixture.cpp - data/DataUtils.cpp - data/Data.cpp - assert/backtrace.cpp - assert/AssertFailed.cpp -) - -add_library(${PROJECT_NAME} STATIC ${SOURCES}) - -# This is needed by boost thread -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE rt) -endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - -TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE curl) - -# TODO From Crypto++ 5.7 on, it should support cmake with find_package(). -find_library(CryptoPP cryptopp) -target_link_libraries(${PROJECT_NAME} PRIVATE ${CryptoPP} scrypt) - -ADD_BOOST(filesystem system thread) -ENABLE_STYLE_WARNINGS() -ACTIVATE_CPP14() +add_subdirectory(cpp-utils) diff --git a/src/cpp-utils/CMakeLists.txt b/src/cpp-utils/CMakeLists.txt new file mode 100644 index 00000000..72ab5c2a --- /dev/null +++ b/src/cpp-utils/CMakeLists.txt @@ -0,0 +1,53 @@ +include(CheckCXXCompilerFlag) + +project (cpp-utils) + +set(SOURCES + crypto/symmetric/ciphers.cpp + crypto/kdf/DerivedKey.cpp + crypto/kdf/Scrypt.cpp + crypto/kdf/DerivedKeyConfig.cpp + crypto/RandomPadding.cpp + process/daemonize.cpp + process/subprocess.cpp + tempfile/TempFile.cpp + tempfile/TempDir.cpp + network/HttpClient.cpp + network/CurlHttpClient.cpp + network/FakeHttpClient.cpp + io/Console.cpp + io/pipestream.cpp + thread/LoopThread.cpp + thread/ThreadSystem.cpp + random/Random.cpp + random/RandomGeneratorThread.cpp + random/OSRandomGenerator.cpp + random/PseudoRandomPool.cpp + random/RandomDataBuffer.cpp + random/RandomGenerator.cpp + lock/LockPool.cpp + data/Serializer.cpp + data/Deserializer.cpp + data/DataFixture.cpp + data/DataUtils.cpp + data/Data.cpp + assert/backtrace.cpp + assert/AssertFailed.cpp +) + +add_library(${PROJECT_NAME} STATIC ${SOURCES}) + +# This is needed by boost thread +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + target_link_libraries(${PROJECT_NAME} PRIVATE rt) +endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + +target_link_libraries(${PROJECT_NAME} PRIVATE curl) + +# TODO From Crypto++ 5.7 on, it should support cmake with find_package(). +find_library(CryptoPP cryptopp) +target_link_libraries(${PROJECT_NAME} PRIVATE ${CryptoPP} scrypt) + +add_boost(${PROJECT_NAME} filesystem system thread) +enable_style_warnings(${PROJECT_NAME}) +activate_cpp14(${PROJECT_NAME}) diff --git a/src/assert/AssertFailed.cpp b/src/cpp-utils/assert/AssertFailed.cpp similarity index 100% rename from src/assert/AssertFailed.cpp rename to src/cpp-utils/assert/AssertFailed.cpp diff --git a/src/assert/AssertFailed.h b/src/cpp-utils/assert/AssertFailed.h similarity index 100% rename from src/assert/AssertFailed.h rename to src/cpp-utils/assert/AssertFailed.h diff --git a/src/assert/assert.h b/src/cpp-utils/assert/assert.h similarity index 100% rename from src/assert/assert.h rename to src/cpp-utils/assert/assert.h diff --git a/src/assert/backtrace.cpp b/src/cpp-utils/assert/backtrace.cpp similarity index 100% rename from src/assert/backtrace.cpp rename to src/cpp-utils/assert/backtrace.cpp diff --git a/src/assert/backtrace.h b/src/cpp-utils/assert/backtrace.h similarity index 100% rename from src/assert/backtrace.h rename to src/cpp-utils/assert/backtrace.h diff --git a/src/crypto/RandomPadding.cpp b/src/cpp-utils/crypto/RandomPadding.cpp similarity index 100% rename from src/crypto/RandomPadding.cpp rename to src/cpp-utils/crypto/RandomPadding.cpp diff --git a/src/crypto/RandomPadding.h b/src/cpp-utils/crypto/RandomPadding.h similarity index 100% rename from src/crypto/RandomPadding.h rename to src/cpp-utils/crypto/RandomPadding.h diff --git a/src/crypto/kdf/DerivedKey.cpp b/src/cpp-utils/crypto/kdf/DerivedKey.cpp similarity index 100% rename from src/crypto/kdf/DerivedKey.cpp rename to src/cpp-utils/crypto/kdf/DerivedKey.cpp diff --git a/src/crypto/kdf/DerivedKey.h b/src/cpp-utils/crypto/kdf/DerivedKey.h similarity index 100% rename from src/crypto/kdf/DerivedKey.h rename to src/cpp-utils/crypto/kdf/DerivedKey.h diff --git a/src/crypto/kdf/DerivedKeyConfig.cpp b/src/cpp-utils/crypto/kdf/DerivedKeyConfig.cpp similarity index 100% rename from src/crypto/kdf/DerivedKeyConfig.cpp rename to src/cpp-utils/crypto/kdf/DerivedKeyConfig.cpp diff --git a/src/crypto/kdf/DerivedKeyConfig.h b/src/cpp-utils/crypto/kdf/DerivedKeyConfig.h similarity index 100% rename from src/crypto/kdf/DerivedKeyConfig.h rename to src/cpp-utils/crypto/kdf/DerivedKeyConfig.h diff --git a/src/crypto/kdf/Scrypt.cpp b/src/cpp-utils/crypto/kdf/Scrypt.cpp similarity index 100% rename from src/crypto/kdf/Scrypt.cpp rename to src/cpp-utils/crypto/kdf/Scrypt.cpp diff --git a/src/crypto/kdf/Scrypt.h b/src/cpp-utils/crypto/kdf/Scrypt.h similarity index 96% rename from src/crypto/kdf/Scrypt.h rename to src/cpp-utils/crypto/kdf/Scrypt.h index 2fc4feaf..6f7adadd 100644 --- a/src/crypto/kdf/Scrypt.h +++ b/src/cpp-utils/crypto/kdf/Scrypt.h @@ -5,7 +5,7 @@ #include "../../macros.h" #include "../../random/Random.h" extern "C" { - #include "../../../vendor/scrypt-1.2.0/lib/crypto/crypto_scrypt.h" + #include "../../../../vendor/scrypt-1.2.0/lib/crypto/crypto_scrypt.h" } #include #include "DerivedKey.h" diff --git a/src/crypto/symmetric/CFB_Cipher.h b/src/cpp-utils/crypto/symmetric/CFB_Cipher.h similarity index 100% rename from src/crypto/symmetric/CFB_Cipher.h rename to src/cpp-utils/crypto/symmetric/CFB_Cipher.h diff --git a/src/crypto/symmetric/Cipher.h b/src/cpp-utils/crypto/symmetric/Cipher.h similarity index 100% rename from src/crypto/symmetric/Cipher.h rename to src/cpp-utils/crypto/symmetric/Cipher.h diff --git a/src/crypto/symmetric/GCM_Cipher.h b/src/cpp-utils/crypto/symmetric/GCM_Cipher.h similarity index 100% rename from src/crypto/symmetric/GCM_Cipher.h rename to src/cpp-utils/crypto/symmetric/GCM_Cipher.h diff --git a/src/crypto/symmetric/ciphers.cpp b/src/cpp-utils/crypto/symmetric/ciphers.cpp similarity index 100% rename from src/crypto/symmetric/ciphers.cpp rename to src/cpp-utils/crypto/symmetric/ciphers.cpp diff --git a/src/crypto/symmetric/ciphers.h b/src/cpp-utils/crypto/symmetric/ciphers.h similarity index 100% rename from src/crypto/symmetric/ciphers.h rename to src/cpp-utils/crypto/symmetric/ciphers.h diff --git a/src/data/Data.cpp b/src/cpp-utils/data/Data.cpp similarity index 100% rename from src/data/Data.cpp rename to src/cpp-utils/data/Data.cpp diff --git a/src/data/Data.h b/src/cpp-utils/data/Data.h similarity index 100% rename from src/data/Data.h rename to src/cpp-utils/data/Data.h diff --git a/src/data/DataFixture.cpp b/src/cpp-utils/data/DataFixture.cpp similarity index 100% rename from src/data/DataFixture.cpp rename to src/cpp-utils/data/DataFixture.cpp diff --git a/src/data/DataFixture.h b/src/cpp-utils/data/DataFixture.h similarity index 100% rename from src/data/DataFixture.h rename to src/cpp-utils/data/DataFixture.h diff --git a/src/data/DataUtils.cpp b/src/cpp-utils/data/DataUtils.cpp similarity index 100% rename from src/data/DataUtils.cpp rename to src/cpp-utils/data/DataUtils.cpp diff --git a/src/data/DataUtils.h b/src/cpp-utils/data/DataUtils.h similarity index 100% rename from src/data/DataUtils.h rename to src/cpp-utils/data/DataUtils.h diff --git a/src/data/Deserializer.cpp b/src/cpp-utils/data/Deserializer.cpp similarity index 100% rename from src/data/Deserializer.cpp rename to src/cpp-utils/data/Deserializer.cpp diff --git a/src/data/Deserializer.h b/src/cpp-utils/data/Deserializer.h similarity index 100% rename from src/data/Deserializer.h rename to src/cpp-utils/data/Deserializer.h diff --git a/src/data/FixedSizeData.h b/src/cpp-utils/data/FixedSizeData.h similarity index 100% rename from src/data/FixedSizeData.h rename to src/cpp-utils/data/FixedSizeData.h diff --git a/src/data/Serializer.cpp b/src/cpp-utils/data/Serializer.cpp similarity index 100% rename from src/data/Serializer.cpp rename to src/cpp-utils/data/Serializer.cpp diff --git a/src/data/Serializer.h b/src/cpp-utils/data/Serializer.h similarity index 100% rename from src/data/Serializer.h rename to src/cpp-utils/data/Serializer.h diff --git a/src/either.h b/src/cpp-utils/either.h similarity index 100% rename from src/either.h rename to src/cpp-utils/either.h diff --git a/src/io/Console.cpp b/src/cpp-utils/io/Console.cpp similarity index 100% rename from src/io/Console.cpp rename to src/cpp-utils/io/Console.cpp diff --git a/src/io/Console.h b/src/cpp-utils/io/Console.h similarity index 100% rename from src/io/Console.h rename to src/cpp-utils/io/Console.h diff --git a/src/io/pipestream.cpp b/src/cpp-utils/io/pipestream.cpp similarity index 100% rename from src/io/pipestream.cpp rename to src/cpp-utils/io/pipestream.cpp diff --git a/src/io/pipestream.h b/src/cpp-utils/io/pipestream.h similarity index 100% rename from src/io/pipestream.h rename to src/cpp-utils/io/pipestream.h diff --git a/src/lock/ConditionBarrier.h b/src/cpp-utils/lock/ConditionBarrier.h similarity index 100% rename from src/lock/ConditionBarrier.h rename to src/cpp-utils/lock/ConditionBarrier.h diff --git a/src/lock/LockPool.cpp b/src/cpp-utils/lock/LockPool.cpp similarity index 100% rename from src/lock/LockPool.cpp rename to src/cpp-utils/lock/LockPool.cpp diff --git a/src/lock/LockPool.h b/src/cpp-utils/lock/LockPool.h similarity index 100% rename from src/lock/LockPool.h rename to src/cpp-utils/lock/LockPool.h diff --git a/src/lock/MutexPoolLock.h b/src/cpp-utils/lock/MutexPoolLock.h similarity index 100% rename from src/lock/MutexPoolLock.h rename to src/cpp-utils/lock/MutexPoolLock.h diff --git a/src/logging/Logger.h b/src/cpp-utils/logging/Logger.h similarity index 96% rename from src/logging/Logger.h rename to src/cpp-utils/logging/Logger.h index dd82acc6..3b7c269d 100644 --- a/src/logging/Logger.h +++ b/src/cpp-utils/logging/Logger.h @@ -2,7 +2,7 @@ #ifndef MESSMER_CPPUTILS_LOGGING_LOGGER_H #define MESSMER_CPPUTILS_LOGGING_LOGGER_H -#include "../../vendor/spdlog/spdlog.h" +#include "../../../vendor/spdlog/spdlog.h" #include "../macros.h" namespace cpputils { diff --git a/src/logging/logging.h b/src/cpp-utils/logging/logging.h similarity index 100% rename from src/logging/logging.h rename to src/cpp-utils/logging/logging.h diff --git a/src/macros.h b/src/cpp-utils/macros.h similarity index 100% rename from src/macros.h rename to src/cpp-utils/macros.h diff --git a/src/network/CurlHttpClient.cpp b/src/cpp-utils/network/CurlHttpClient.cpp similarity index 100% rename from src/network/CurlHttpClient.cpp rename to src/cpp-utils/network/CurlHttpClient.cpp diff --git a/src/network/CurlHttpClient.h b/src/cpp-utils/network/CurlHttpClient.h similarity index 100% rename from src/network/CurlHttpClient.h rename to src/cpp-utils/network/CurlHttpClient.h diff --git a/src/network/FakeHttpClient.cpp b/src/cpp-utils/network/FakeHttpClient.cpp similarity index 100% rename from src/network/FakeHttpClient.cpp rename to src/cpp-utils/network/FakeHttpClient.cpp diff --git a/src/network/FakeHttpClient.h b/src/cpp-utils/network/FakeHttpClient.h similarity index 100% rename from src/network/FakeHttpClient.h rename to src/cpp-utils/network/FakeHttpClient.h diff --git a/src/network/HttpClient.cpp b/src/cpp-utils/network/HttpClient.cpp similarity index 100% rename from src/network/HttpClient.cpp rename to src/cpp-utils/network/HttpClient.cpp diff --git a/src/network/HttpClient.h b/src/cpp-utils/network/HttpClient.h similarity index 100% rename from src/network/HttpClient.h rename to src/cpp-utils/network/HttpClient.h diff --git a/src/pointer/cast.h b/src/cpp-utils/pointer/cast.h similarity index 100% rename from src/pointer/cast.h rename to src/cpp-utils/pointer/cast.h diff --git a/src/pointer/gcc_4_8_compatibility.h b/src/cpp-utils/pointer/gcc_4_8_compatibility.h similarity index 100% rename from src/pointer/gcc_4_8_compatibility.h rename to src/cpp-utils/pointer/gcc_4_8_compatibility.h diff --git a/src/pointer/optional_ownership_ptr.h b/src/cpp-utils/pointer/optional_ownership_ptr.h similarity index 100% rename from src/pointer/optional_ownership_ptr.h rename to src/cpp-utils/pointer/optional_ownership_ptr.h diff --git a/src/pointer/unique_ref.h b/src/cpp-utils/pointer/unique_ref.h similarity index 100% rename from src/pointer/unique_ref.h rename to src/cpp-utils/pointer/unique_ref.h diff --git a/src/pointer/unique_ref_boost_optional_gtest_workaround.h b/src/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h similarity index 100% rename from src/pointer/unique_ref_boost_optional_gtest_workaround.h rename to src/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h diff --git a/src/process/daemonize.cpp b/src/cpp-utils/process/daemonize.cpp similarity index 100% rename from src/process/daemonize.cpp rename to src/cpp-utils/process/daemonize.cpp diff --git a/src/process/daemonize.h b/src/cpp-utils/process/daemonize.h similarity index 100% rename from src/process/daemonize.h rename to src/cpp-utils/process/daemonize.h diff --git a/src/process/subprocess.cpp b/src/cpp-utils/process/subprocess.cpp similarity index 100% rename from src/process/subprocess.cpp rename to src/cpp-utils/process/subprocess.cpp diff --git a/src/process/subprocess.h b/src/cpp-utils/process/subprocess.h similarity index 100% rename from src/process/subprocess.h rename to src/cpp-utils/process/subprocess.h diff --git a/src/random/OSRandomGenerator.cpp b/src/cpp-utils/random/OSRandomGenerator.cpp similarity index 100% rename from src/random/OSRandomGenerator.cpp rename to src/cpp-utils/random/OSRandomGenerator.cpp diff --git a/src/random/OSRandomGenerator.h b/src/cpp-utils/random/OSRandomGenerator.h similarity index 100% rename from src/random/OSRandomGenerator.h rename to src/cpp-utils/random/OSRandomGenerator.h diff --git a/src/random/PseudoRandomPool.cpp b/src/cpp-utils/random/PseudoRandomPool.cpp similarity index 100% rename from src/random/PseudoRandomPool.cpp rename to src/cpp-utils/random/PseudoRandomPool.cpp diff --git a/src/random/PseudoRandomPool.h b/src/cpp-utils/random/PseudoRandomPool.h similarity index 100% rename from src/random/PseudoRandomPool.h rename to src/cpp-utils/random/PseudoRandomPool.h diff --git a/src/random/Random.cpp b/src/cpp-utils/random/Random.cpp similarity index 100% rename from src/random/Random.cpp rename to src/cpp-utils/random/Random.cpp diff --git a/src/random/Random.h b/src/cpp-utils/random/Random.h similarity index 100% rename from src/random/Random.h rename to src/cpp-utils/random/Random.h diff --git a/src/random/RandomDataBuffer.cpp b/src/cpp-utils/random/RandomDataBuffer.cpp similarity index 100% rename from src/random/RandomDataBuffer.cpp rename to src/cpp-utils/random/RandomDataBuffer.cpp diff --git a/src/random/RandomDataBuffer.h b/src/cpp-utils/random/RandomDataBuffer.h similarity index 100% rename from src/random/RandomDataBuffer.h rename to src/cpp-utils/random/RandomDataBuffer.h diff --git a/src/random/RandomGenerator.cpp b/src/cpp-utils/random/RandomGenerator.cpp similarity index 100% rename from src/random/RandomGenerator.cpp rename to src/cpp-utils/random/RandomGenerator.cpp diff --git a/src/random/RandomGenerator.h b/src/cpp-utils/random/RandomGenerator.h similarity index 100% rename from src/random/RandomGenerator.h rename to src/cpp-utils/random/RandomGenerator.h diff --git a/src/random/RandomGeneratorThread.cpp b/src/cpp-utils/random/RandomGeneratorThread.cpp similarity index 100% rename from src/random/RandomGeneratorThread.cpp rename to src/cpp-utils/random/RandomGeneratorThread.cpp diff --git a/src/random/RandomGeneratorThread.h b/src/cpp-utils/random/RandomGeneratorThread.h similarity index 100% rename from src/random/RandomGeneratorThread.h rename to src/cpp-utils/random/RandomGeneratorThread.h diff --git a/src/random/ThreadsafeRandomDataBuffer.h b/src/cpp-utils/random/ThreadsafeRandomDataBuffer.h similarity index 100% rename from src/random/ThreadsafeRandomDataBuffer.h rename to src/cpp-utils/random/ThreadsafeRandomDataBuffer.h diff --git a/src/tempfile/TempDir.cpp b/src/cpp-utils/tempfile/TempDir.cpp similarity index 100% rename from src/tempfile/TempDir.cpp rename to src/cpp-utils/tempfile/TempDir.cpp diff --git a/src/tempfile/TempDir.h b/src/cpp-utils/tempfile/TempDir.h similarity index 100% rename from src/tempfile/TempDir.h rename to src/cpp-utils/tempfile/TempDir.h diff --git a/src/tempfile/TempFile.cpp b/src/cpp-utils/tempfile/TempFile.cpp similarity index 100% rename from src/tempfile/TempFile.cpp rename to src/cpp-utils/tempfile/TempFile.cpp diff --git a/src/tempfile/TempFile.h b/src/cpp-utils/tempfile/TempFile.h similarity index 100% rename from src/tempfile/TempFile.h rename to src/cpp-utils/tempfile/TempFile.h diff --git a/src/thread/LoopThread.cpp b/src/cpp-utils/thread/LoopThread.cpp similarity index 100% rename from src/thread/LoopThread.cpp rename to src/cpp-utils/thread/LoopThread.cpp diff --git a/src/thread/LoopThread.h b/src/cpp-utils/thread/LoopThread.h similarity index 100% rename from src/thread/LoopThread.h rename to src/cpp-utils/thread/LoopThread.h diff --git a/src/thread/ThreadSystem.cpp b/src/cpp-utils/thread/ThreadSystem.cpp similarity index 100% rename from src/thread/ThreadSystem.cpp rename to src/cpp-utils/thread/ThreadSystem.cpp diff --git a/src/thread/ThreadSystem.h b/src/cpp-utils/thread/ThreadSystem.h similarity index 100% rename from src/thread/ThreadSystem.h rename to src/cpp-utils/thread/ThreadSystem.h diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d79d7ca7..b39fe26b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,60 +1,5 @@ -project (cpp-utils-test) - -set(SOURCES - EitherIncludeTest.cpp - crypto/symmetric/CipherTest.cpp - crypto/symmetric/testutils/FakeAuthenticatedCipher.cpp - crypto/kdf/SCryptTest.cpp - crypto/kdf/DerivedKeyTest.cpp - crypto/kdf/DerivedKeyConfigTest.cpp - MacrosIncludeTest.cpp - pointer/unique_ref_test.cpp - pointer/cast_include_test.cpp - pointer/cast_test.cpp - pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp - pointer/optional_ownership_ptr_include_test.cpp - pointer/optional_ownership_ptr_test.cpp - pointer/unique_ref_include_test.cpp - process/daemonize_include_test.cpp - process/subprocess_include_test.cpp - tempfile/TempFileTest.cpp - tempfile/TempFileIncludeTest.cpp - tempfile/TempDirIncludeTest.cpp - tempfile/TempDirTest.cpp - network/CurlHttpClientTest.cpp - network/FakeHttpClientTest.cpp - io/ConsoleIncludeTest.cpp - io/ConsoleTest_AskYesNo.cpp - io/ConsoleTest_Print.cpp - io/ConsoleTest_Ask.cpp - random/RandomIncludeTest.cpp - lock/LockPoolIncludeTest.cpp - lock/ConditionBarrierIncludeTest.cpp - lock/MutexPoolLockIncludeTest.cpp - data/FixedSizeDataTest.cpp - data/DataFixtureIncludeTest.cpp - data/DataFixtureTest.cpp - data/DataTest.cpp - data/FixedSizeDataIncludeTest.cpp - data/DataIncludeTest.cpp - logging/LoggingLevelTest.cpp - logging/LoggerTest.cpp - logging/LoggingTest.cpp - logging/LoggerIncludeTest.cpp - logging/LoggingIncludeTest.cpp - EitherTest.cpp - assert/assert_release_test.cpp - assert/backtrace_include_test.cpp - assert/assert_include_test.cpp - assert/assert_debug_test.cpp -) - enable_testing() -include_directories(${PROJECT_NAME} SYSTEM ${gtest_INCLUDE_DIRS}/include SYSTEM ${gmock_INCLUDE_DIRS}/include) -add_executable(${PROJECT_NAME} ${SOURCES}) -target_link_libraries(${PROJECT_NAME} gtest gmock gmock_main) -add_test(${PROJECT_NAME} ${PROJECT_NAME}) +include_directories(SYSTEM ${gtest_INCLUDE_DIRS}/include SYSTEM ${gmock_INCLUDE_DIRS}/include) +link_libraries(gtest gmock gmock_main) -target_link_libraries(${PROJECT_NAME} cpp-utils) -enable_style_warnings() -activate_cpp14() \ No newline at end of file +add_subdirectory(cpp-utils) \ No newline at end of file diff --git a/test/cpp-utils/CMakeLists.txt b/test/cpp-utils/CMakeLists.txt new file mode 100644 index 00000000..652fec8a --- /dev/null +++ b/test/cpp-utils/CMakeLists.txt @@ -0,0 +1,57 @@ +project (cpp-utils-test) + +set(SOURCES + EitherIncludeTest.cpp + crypto/symmetric/CipherTest.cpp + crypto/symmetric/testutils/FakeAuthenticatedCipher.cpp + crypto/kdf/SCryptTest.cpp + crypto/kdf/DerivedKeyTest.cpp + crypto/kdf/DerivedKeyConfigTest.cpp + MacrosIncludeTest.cpp + pointer/unique_ref_test.cpp + pointer/cast_include_test.cpp + pointer/cast_test.cpp + pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp + pointer/optional_ownership_ptr_include_test.cpp + pointer/optional_ownership_ptr_test.cpp + pointer/unique_ref_include_test.cpp + process/daemonize_include_test.cpp + process/subprocess_include_test.cpp + tempfile/TempFileTest.cpp + tempfile/TempFileIncludeTest.cpp + tempfile/TempDirIncludeTest.cpp + tempfile/TempDirTest.cpp + network/CurlHttpClientTest.cpp + network/FakeHttpClientTest.cpp + io/ConsoleIncludeTest.cpp + io/ConsoleTest_AskYesNo.cpp + io/ConsoleTest_Print.cpp + io/ConsoleTest_Ask.cpp + random/RandomIncludeTest.cpp + lock/LockPoolIncludeTest.cpp + lock/ConditionBarrierIncludeTest.cpp + lock/MutexPoolLockIncludeTest.cpp + data/FixedSizeDataTest.cpp + data/DataFixtureIncludeTest.cpp + data/DataFixtureTest.cpp + data/DataTest.cpp + data/FixedSizeDataIncludeTest.cpp + data/DataIncludeTest.cpp + logging/LoggingLevelTest.cpp + logging/LoggerTest.cpp + logging/LoggingTest.cpp + logging/LoggerIncludeTest.cpp + logging/LoggingIncludeTest.cpp + EitherTest.cpp + assert/assert_release_test.cpp + assert/backtrace_include_test.cpp + assert/assert_include_test.cpp + assert/assert_debug_test.cpp +) + +add_executable(${PROJECT_NAME} ${SOURCES}) +target_link_libraries(${PROJECT_NAME} cpp-utils) +add_test(${PROJECT_NAME} ${PROJECT_NAME}) + +enable_style_warnings(${PROJECT_NAME}) +activate_cpp14(${PROJECT_NAME}) diff --git a/test/EitherIncludeTest.cpp b/test/cpp-utils/EitherIncludeTest.cpp similarity index 65% rename from test/EitherIncludeTest.cpp rename to test/cpp-utils/EitherIncludeTest.cpp index 314c1aba..d8355891 100644 --- a/test/EitherIncludeTest.cpp +++ b/test/cpp-utils/EitherIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../src/either.h" +#include "../../src/cpp-utils/either.h" //Test that either can be included without needing additional dependencies diff --git a/test/EitherTest.cpp b/test/cpp-utils/EitherTest.cpp similarity index 99% rename from test/EitherTest.cpp rename to test/cpp-utils/EitherTest.cpp index 82070503..094e7cfe 100644 --- a/test/EitherTest.cpp +++ b/test/cpp-utils/EitherTest.cpp @@ -1,8 +1,8 @@ #include #include #include -#include "../src/either.h" -#include "../src/macros.h" +#include "../../src/cpp-utils/either.h" +#include "../../src/cpp-utils/macros.h" #include //TODO Go through all test cases and think about whether it makes sense to add the same test case but with primitive types. diff --git a/test/MacrosIncludeTest.cpp b/test/cpp-utils/MacrosIncludeTest.cpp similarity index 66% rename from test/MacrosIncludeTest.cpp rename to test/cpp-utils/MacrosIncludeTest.cpp index 2187d85c..4a181d69 100644 --- a/test/MacrosIncludeTest.cpp +++ b/test/cpp-utils/MacrosIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../src/macros.h" +#include "../../src/cpp-utils/macros.h" // Test that macros.h can be included without needing additional dependencies diff --git a/test/assert/assert_debug_test.cpp b/test/cpp-utils/assert/assert_debug_test.cpp similarity index 91% rename from test/assert/assert_debug_test.cpp rename to test/cpp-utils/assert/assert_debug_test.cpp index 5c7eb82f..787830b8 100644 --- a/test/assert/assert_debug_test.cpp +++ b/test/cpp-utils/assert/assert_debug_test.cpp @@ -3,7 +3,7 @@ //Include the ASSERT macro for a debug build #undef NDEBUG -#include "../../src/assert/assert.h" +#include "../../../src/cpp-utils/assert/assert.h" using testing::MatchesRegex; diff --git a/test/assert/assert_include_test.cpp b/test/cpp-utils/assert/assert_include_test.cpp similarity index 60% rename from test/assert/assert_include_test.cpp rename to test/cpp-utils/assert/assert_include_test.cpp index 308d3a8e..3a85c2dc 100644 --- a/test/assert/assert_include_test.cpp +++ b/test/cpp-utils/assert/assert_include_test.cpp @@ -1,3 +1,3 @@ -#include "../../src/assert/assert.h" +#include "../../../src/cpp-utils/assert/assert.h" // Test the header can be included without needing additional dependencies diff --git a/test/assert/assert_release_test.cpp b/test/cpp-utils/assert/assert_release_test.cpp similarity index 92% rename from test/assert/assert_release_test.cpp rename to test/cpp-utils/assert/assert_release_test.cpp index ca8d5505..f67769a1 100644 --- a/test/assert/assert_release_test.cpp +++ b/test/cpp-utils/assert/assert_release_test.cpp @@ -3,7 +3,7 @@ //Include the ASSERT macro for a release build #define NDEBUG -#include "../../src/assert/assert.h" +#include "../../../src/cpp-utils/assert/assert.h" using testing::MatchesRegex; diff --git a/test/assert/backtrace_include_test.cpp b/test/cpp-utils/assert/backtrace_include_test.cpp similarity index 59% rename from test/assert/backtrace_include_test.cpp rename to test/cpp-utils/assert/backtrace_include_test.cpp index 385eeea3..be2f53ae 100644 --- a/test/assert/backtrace_include_test.cpp +++ b/test/cpp-utils/assert/backtrace_include_test.cpp @@ -1,4 +1,4 @@ -#include "../../src/assert/backtrace.h" +#include "../../../src/cpp-utils/assert/backtrace.h" // Test the header can be included without needing additional dependencies diff --git a/test/crypto/kdf/DerivedKeyConfigTest.cpp b/test/cpp-utils/crypto/kdf/DerivedKeyConfigTest.cpp similarity index 84% rename from test/crypto/kdf/DerivedKeyConfigTest.cpp rename to test/cpp-utils/crypto/kdf/DerivedKeyConfigTest.cpp index 62473226..6e268b92 100644 --- a/test/crypto/kdf/DerivedKeyConfigTest.cpp +++ b/test/cpp-utils/crypto/kdf/DerivedKeyConfigTest.cpp @@ -1,6 +1,6 @@ #include -#include "../../../src/crypto/kdf/DerivedKeyConfig.h" -#include "../../../src/data/DataFixture.h" +#include "../../../../src/cpp-utils/crypto/kdf/DerivedKeyConfig.h" +#include "../../../../src/cpp-utils/data/DataFixture.h" #include using namespace cpputils; @@ -35,52 +35,52 @@ TEST_F(DerivedKeyConfigTest, Salt_SaveAndLoad) { TEST_F(DerivedKeyConfigTest, N) { DerivedKeyConfig cfg(Data(0), 1024, 0, 0); - EXPECT_EQ(1024, cfg.N()); + EXPECT_EQ(1024u, cfg.N()); } TEST_F(DerivedKeyConfigTest, N_Move) { DerivedKeyConfig cfg(Data(0), 1024, 0, 0); DerivedKeyConfig moved = std::move(cfg); - EXPECT_EQ(1024, moved.N()); + EXPECT_EQ(1024u, moved.N()); } TEST_F(DerivedKeyConfigTest, N_SaveAndLoad) { DerivedKeyConfig cfg(Data(0), 1024, 0, 0); DerivedKeyConfig loaded = SaveAndLoad(cfg); - EXPECT_EQ(1024, loaded.N()); + EXPECT_EQ(1024u, loaded.N()); } TEST_F(DerivedKeyConfigTest, r) { DerivedKeyConfig cfg(Data(0), 0, 8, 0); - EXPECT_EQ(8, cfg.r()); + EXPECT_EQ(8u, cfg.r()); } TEST_F(DerivedKeyConfigTest, r_Move) { DerivedKeyConfig cfg(Data(0), 0, 8, 0); DerivedKeyConfig moved = std::move(cfg); - EXPECT_EQ(8, moved.r()); + EXPECT_EQ(8u, moved.r()); } TEST_F(DerivedKeyConfigTest, r_SaveAndLoad) { DerivedKeyConfig cfg(Data(0), 0, 8, 0); DerivedKeyConfig loaded = SaveAndLoad(cfg); - EXPECT_EQ(8, loaded.r()); + EXPECT_EQ(8u, loaded.r()); } TEST_F(DerivedKeyConfigTest, p) { DerivedKeyConfig cfg(Data(0), 0, 0, 16); - EXPECT_EQ(16, cfg.p()); + EXPECT_EQ(16u, cfg.p()); } TEST_F(DerivedKeyConfigTest, p_Move) { DerivedKeyConfig cfg(Data(0), 0, 0, 16); DerivedKeyConfig moved = std::move(cfg); - EXPECT_EQ(16, moved.p()); + EXPECT_EQ(16u, moved.p()); } TEST_F(DerivedKeyConfigTest, p_SaveAndLoad) { DerivedKeyConfig cfg(Data(0), 0, 0, 16); DerivedKeyConfig loaded = SaveAndLoad(cfg); - EXPECT_EQ(16, loaded.p()); + EXPECT_EQ(16u, loaded.p()); } \ No newline at end of file diff --git a/test/crypto/kdf/DerivedKeyTest.cpp b/test/cpp-utils/crypto/kdf/DerivedKeyTest.cpp similarity index 68% rename from test/crypto/kdf/DerivedKeyTest.cpp rename to test/cpp-utils/crypto/kdf/DerivedKeyTest.cpp index 5476c1c1..20522148 100644 --- a/test/crypto/kdf/DerivedKeyTest.cpp +++ b/test/cpp-utils/crypto/kdf/DerivedKeyTest.cpp @@ -1,15 +1,15 @@ #include -#include "../../../src/crypto/kdf/DerivedKey.h" -#include "../../../src/data/DataFixture.h" +#include "../../../../src/cpp-utils/crypto/kdf/DerivedKey.h" +#include "../../../../src/cpp-utils/data/DataFixture.h" using namespace cpputils; TEST(DerivedKeyTest, Config) { DerivedKey<32> key(DerivedKeyConfig(DataFixture::generate(32, 1), 1024, 8, 16), DataFixture::generateFixedSize<32>(2)); EXPECT_EQ(DataFixture::generate(32, 1), key.config().salt()); - EXPECT_EQ(1024, key.config().N()); - EXPECT_EQ(8, key.config().r()); - EXPECT_EQ(16, key.config().p()); + EXPECT_EQ(1024u, key.config().N()); + EXPECT_EQ(8u, key.config().r()); + EXPECT_EQ(16u, key.config().p()); } TEST(DerivedKeyTest, Key) { diff --git a/test/crypto/kdf/SCryptTest.cpp b/test/cpp-utils/crypto/kdf/SCryptTest.cpp similarity index 97% rename from test/crypto/kdf/SCryptTest.cpp rename to test/cpp-utils/crypto/kdf/SCryptTest.cpp index 5accb4db..f815fce0 100644 --- a/test/crypto/kdf/SCryptTest.cpp +++ b/test/cpp-utils/crypto/kdf/SCryptTest.cpp @@ -1,5 +1,5 @@ #include -#include "../../../src/crypto/kdf/Scrypt.h" +#include "../../../../src/cpp-utils/crypto/kdf/Scrypt.h" using namespace cpputils; diff --git a/test/crypto/symmetric/CipherTest.cpp b/test/cpp-utils/crypto/symmetric/CipherTest.cpp similarity index 97% rename from test/crypto/symmetric/CipherTest.cpp rename to test/cpp-utils/crypto/symmetric/CipherTest.cpp index c8eca870..7da67916 100644 --- a/test/crypto/symmetric/CipherTest.cpp +++ b/test/cpp-utils/crypto/symmetric/CipherTest.cpp @@ -1,10 +1,10 @@ #include -#include "../../../src/crypto/symmetric/Cipher.h" -#include "../../../src/crypto/symmetric/ciphers.h" +#include "../../../../src/cpp-utils/crypto/symmetric/Cipher.h" +#include "../../../../src/cpp-utils/crypto/symmetric/ciphers.h" #include "testutils/FakeAuthenticatedCipher.h" -#include "../../../src/data/DataFixture.h" -#include "../../../src/data/Data.h" +#include "../../../../src/cpp-utils/data/DataFixture.h" +#include "../../../../src/cpp-utils/data/Data.h" #include using namespace cpputils; diff --git a/test/crypto/symmetric/testutils/FakeAuthenticatedCipher.cpp b/test/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.cpp similarity index 100% rename from test/crypto/symmetric/testutils/FakeAuthenticatedCipher.cpp rename to test/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.cpp diff --git a/test/crypto/symmetric/testutils/FakeAuthenticatedCipher.h b/test/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h similarity index 93% rename from test/crypto/symmetric/testutils/FakeAuthenticatedCipher.h rename to test/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h index d7ae41ec..45d889ba 100644 --- a/test/crypto/symmetric/testutils/FakeAuthenticatedCipher.h +++ b/test/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h @@ -2,10 +2,10 @@ #ifndef MESSMER_CPPUTILS_TEST_CRYPTO_SYMMETRIC_TESTUTILS_FAKEAUTHENTICATEDCIPHER_H_ #define MESSMER_CPPUTILS_TEST_CRYPTO_SYMMETRIC_TESTUTILS_FAKEAUTHENTICATEDCIPHER_H_ -#include "../../../../src/crypto/symmetric/Cipher.h" -#include "../../../../src/data/FixedSizeData.h" -#include "../../../../src/data/Data.h" -#include "../../../../src/random/RandomGenerator.h" +#include "../../../../../src/cpp-utils/crypto/symmetric/Cipher.h" +#include "../../../../../src/cpp-utils/data/FixedSizeData.h" +#include "../../../../../src/cpp-utils/data/Data.h" +#include "../../../../../src/cpp-utils/random/RandomGenerator.h" namespace cpputils { diff --git a/test/data/DataFixtureIncludeTest.cpp b/test/cpp-utils/data/DataFixtureIncludeTest.cpp similarity index 50% rename from test/data/DataFixtureIncludeTest.cpp rename to test/cpp-utils/data/DataFixtureIncludeTest.cpp index 88cbb8de..318deff3 100644 --- a/test/data/DataFixtureIncludeTest.cpp +++ b/test/cpp-utils/data/DataFixtureIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/data/DataFixture.h" +#include "../../../src/cpp-utils/data/DataFixture.h" // Test the header can be included without needing additional dependencies \ No newline at end of file diff --git a/test/data/DataFixtureTest.cpp b/test/cpp-utils/data/DataFixtureTest.cpp similarity index 91% rename from test/data/DataFixtureTest.cpp rename to test/cpp-utils/data/DataFixtureTest.cpp index 96945358..6a982cda 100644 --- a/test/data/DataFixtureTest.cpp +++ b/test/cpp-utils/data/DataFixtureTest.cpp @@ -1,7 +1,7 @@ #include -#include "../../src/data/Data.h" -#include "../../src/data/DataFixture.h" +#include "../../../src/cpp-utils/data/Data.h" +#include "../../../src/cpp-utils/data/DataFixture.h" using ::testing::Test; using ::testing::WithParamInterface; @@ -16,17 +16,17 @@ class DataFixtureTest: public Test { TEST_F(DataFixtureTest, CreateEmptyFixture) { Data data = DataFixture::generate(0); - EXPECT_EQ(0, data.size()); + EXPECT_EQ(0u, data.size()); } TEST_F(DataFixtureTest, CreateOneByteFixture) { Data data = DataFixture::generate(1); - EXPECT_EQ(1, data.size()); + EXPECT_EQ(1u, data.size()); } TEST_F(DataFixtureTest, CreateLargerFixture) { Data data = DataFixture::generate(20 * 1024 * 1024); - EXPECT_EQ(20 * 1024 * 1024, data.size()); + EXPECT_EQ(20u * 1024u * 1024u, data.size()); } TEST_F(DataFixtureTest, FixturesAreDeterministic_DefaultSeed) { diff --git a/test/data/DataIncludeTest.cpp b/test/cpp-utils/data/DataIncludeTest.cpp similarity index 53% rename from test/data/DataIncludeTest.cpp rename to test/cpp-utils/data/DataIncludeTest.cpp index 2df6ad6f..a0e97317 100644 --- a/test/data/DataIncludeTest.cpp +++ b/test/cpp-utils/data/DataIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/data/Data.h" +#include "../../../src/cpp-utils/data/Data.h" // Test the header can be included without needing additional dependencies \ No newline at end of file diff --git a/test/data/DataTest.cpp b/test/cpp-utils/data/DataTest.cpp similarity index 96% rename from test/data/DataTest.cpp rename to test/cpp-utils/data/DataTest.cpp index 0edd2ee8..e8e23d76 100644 --- a/test/data/DataTest.cpp +++ b/test/cpp-utils/data/DataTest.cpp @@ -1,8 +1,8 @@ -#include "../../src/data/DataFixture.h" -#include "../../src/data/Data.h" +#include "../../../src/cpp-utils/data/DataFixture.h" +#include "../../../src/cpp-utils/data/Data.h" #include -#include "../../src/tempfile/TempFile.h" +#include "../../../src/cpp-utils/tempfile/TempFile.h" #include @@ -141,7 +141,7 @@ TEST_F(DataTest, MoveConstructor) { Data copy(std::move(original)); EXPECT_EQ(DataFixture::generate(1024), copy); EXPECT_EQ(nullptr, original.data()); - EXPECT_EQ(0, original.size()); + EXPECT_EQ(0u, original.size()); } TEST_F(DataTest, MoveAssignment) { @@ -150,7 +150,7 @@ TEST_F(DataTest, MoveAssignment) { copy = std::move(original); EXPECT_EQ(DataFixture::generate(1024), copy); EXPECT_EQ(nullptr, original.data()); - EXPECT_EQ(0, original.size()); + EXPECT_EQ(0u, original.size()); } TEST_F(DataTest, Equality) { diff --git a/test/data/FixedSizeDataIncludeTest.cpp b/test/cpp-utils/data/FixedSizeDataIncludeTest.cpp similarity index 50% rename from test/data/FixedSizeDataIncludeTest.cpp rename to test/cpp-utils/data/FixedSizeDataIncludeTest.cpp index 49e06c80..f69ef1d9 100644 --- a/test/data/FixedSizeDataIncludeTest.cpp +++ b/test/cpp-utils/data/FixedSizeDataIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/data/FixedSizeData.h" +#include "../../../src/cpp-utils/data/FixedSizeData.h" // Test the header can be included without needing additional dependencies \ No newline at end of file diff --git a/test/data/FixedSizeDataTest.cpp b/test/cpp-utils/data/FixedSizeDataTest.cpp similarity index 97% rename from test/data/FixedSizeDataTest.cpp rename to test/cpp-utils/data/FixedSizeDataTest.cpp index 8cbc13f3..533a0ee8 100644 --- a/test/data/FixedSizeDataTest.cpp +++ b/test/cpp-utils/data/FixedSizeDataTest.cpp @@ -1,6 +1,6 @@ -#include "../../src/data/DataFixture.h" -#include "../../src/data/FixedSizeData.h" -#include "../../src/data/Data.h" +#include "../../../src/cpp-utils/data/DataFixture.h" +#include "../../../src/cpp-utils/data/FixedSizeData.h" +#include "../../../src/cpp-utils/data/Data.h" #include diff --git a/test/io/ConsoleIncludeTest.cpp b/test/cpp-utils/io/ConsoleIncludeTest.cpp similarity index 61% rename from test/io/ConsoleIncludeTest.cpp rename to test/cpp-utils/io/ConsoleIncludeTest.cpp index e95d35ab..c5afe80b 100644 --- a/test/io/ConsoleIncludeTest.cpp +++ b/test/cpp-utils/io/ConsoleIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/io/Console.h" +#include "../../../src/cpp-utils/io/Console.h" // Test the header can be included without needing additional dependencies diff --git a/test/io/ConsoleTest.h b/test/cpp-utils/io/ConsoleTest.h similarity index 95% rename from test/io/ConsoleTest.h rename to test/cpp-utils/io/ConsoleTest.h index 8b539563..993d3ed5 100644 --- a/test/io/ConsoleTest.h +++ b/test/cpp-utils/io/ConsoleTest.h @@ -4,11 +4,11 @@ #include -#include "../../src/io/Console.h" +#include "../../../src/cpp-utils/io/Console.h" #include #include -#include "../../src/io/pipestream.h" +#include "../../../src/cpp-utils/io/pipestream.h" class ConsoleThread { public: diff --git a/test/io/ConsoleTest_Ask.cpp b/test/cpp-utils/io/ConsoleTest_Ask.cpp similarity index 93% rename from test/io/ConsoleTest_Ask.cpp rename to test/cpp-utils/io/ConsoleTest_Ask.cpp index dc828605..400680ad 100644 --- a/test/io/ConsoleTest_Ask.cpp +++ b/test/cpp-utils/io/ConsoleTest_Ask.cpp @@ -25,7 +25,7 @@ TEST_F(ConsoleTest_Ask, OneOption) { }); EXPECT_OUTPUT_LINE("Your choice [1-1]", ':', " "); sendInputLine("1"); - EXPECT_EQ(0, chosen.get()); + EXPECT_EQ(0u, chosen.get()); } TEST_F(ConsoleTest_Ask, TwoOptions_ChooseFirst) { @@ -37,7 +37,7 @@ TEST_F(ConsoleTest_Ask, TwoOptions_ChooseFirst) { }); EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); sendInputLine("1"); - EXPECT_EQ(0, chosen.get()); + EXPECT_EQ(0u, chosen.get()); } TEST_F(ConsoleTest_Ask, TwoOptions_ChooseSecond) { @@ -49,7 +49,7 @@ TEST_F(ConsoleTest_Ask, TwoOptions_ChooseSecond) { }); EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); + EXPECT_EQ(1u, chosen.get()); } TEST_F(ConsoleTest_Ask, ThreeOptions_ChooseFirst) { @@ -62,7 +62,7 @@ TEST_F(ConsoleTest_Ask, ThreeOptions_ChooseFirst) { }); EXPECT_OUTPUT_LINE("Your choice [1-3]", ':', " "); sendInputLine("1"); - EXPECT_EQ(0, chosen.get()); + EXPECT_EQ(0u, chosen.get()); } TEST_F(ConsoleTest_Ask, ThreeOptions_ChooseSecond) { @@ -75,7 +75,7 @@ TEST_F(ConsoleTest_Ask, ThreeOptions_ChooseSecond) { }); EXPECT_OUTPUT_LINE("Your choice [1-3]", ':', " "); sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); + EXPECT_EQ(1u, chosen.get()); } TEST_F(ConsoleTest_Ask, ThreeOptions_ChooseThird) { @@ -88,7 +88,7 @@ TEST_F(ConsoleTest_Ask, ThreeOptions_ChooseThird) { }); EXPECT_OUTPUT_LINE("Your choice [1-3]", ':', " "); sendInputLine("3"); - EXPECT_EQ(2, chosen.get()); + EXPECT_EQ(2u, chosen.get()); } TEST_F(ConsoleTest_Ask, InputWithLeadingSpaces) { @@ -100,7 +100,7 @@ TEST_F(ConsoleTest_Ask, InputWithLeadingSpaces) { }); EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); sendInputLine(" 2"); - EXPECT_EQ(1, chosen.get()); + EXPECT_EQ(1u, chosen.get()); } TEST_F(ConsoleTest_Ask, InputWithFollowingSpaces) { @@ -112,7 +112,7 @@ TEST_F(ConsoleTest_Ask, InputWithFollowingSpaces) { }); EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); sendInputLine("2 "); - EXPECT_EQ(1, chosen.get()); + EXPECT_EQ(1u, chosen.get()); } TEST_F(ConsoleTest_Ask, InputWithLeadingAndFollowingSpaces) { @@ -124,7 +124,7 @@ TEST_F(ConsoleTest_Ask, InputWithLeadingAndFollowingSpaces) { }); EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); sendInputLine(" 2 "); - EXPECT_EQ(1, chosen.get()); + EXPECT_EQ(1u, chosen.get()); } TEST_F(ConsoleTest_Ask, InputEmptyLine) { @@ -140,7 +140,7 @@ TEST_F(ConsoleTest_Ask, InputEmptyLine) { sendInputLine(" "); // empty line with space EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); + EXPECT_EQ(1u, chosen.get()); } TEST_F(ConsoleTest_Ask, InputWrongNumbers) { @@ -162,7 +162,7 @@ TEST_F(ConsoleTest_Ask, InputWrongNumbers) { sendInputLine("1,5"); EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); + EXPECT_EQ(1u, chosen.get()); } TEST_F(ConsoleTest_Ask, InputNonNumbers) { @@ -184,5 +184,5 @@ TEST_F(ConsoleTest_Ask, InputNonNumbers) { sendInputLine("a1"); // Right number but string attached EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); + EXPECT_EQ(1u, chosen.get()); } \ No newline at end of file diff --git a/test/io/ConsoleTest_AskYesNo.cpp b/test/cpp-utils/io/ConsoleTest_AskYesNo.cpp similarity index 100% rename from test/io/ConsoleTest_AskYesNo.cpp rename to test/cpp-utils/io/ConsoleTest_AskYesNo.cpp diff --git a/test/io/ConsoleTest_Print.cpp b/test/cpp-utils/io/ConsoleTest_Print.cpp similarity index 100% rename from test/io/ConsoleTest_Print.cpp rename to test/cpp-utils/io/ConsoleTest_Print.cpp diff --git a/test/lock/ConditionBarrierIncludeTest.cpp b/test/cpp-utils/lock/ConditionBarrierIncludeTest.cpp similarity index 56% rename from test/lock/ConditionBarrierIncludeTest.cpp rename to test/cpp-utils/lock/ConditionBarrierIncludeTest.cpp index a6acba2f..87a7ac5c 100644 --- a/test/lock/ConditionBarrierIncludeTest.cpp +++ b/test/cpp-utils/lock/ConditionBarrierIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/lock/ConditionBarrier.h" +#include "../../../src/cpp-utils/lock/ConditionBarrier.h" // Test the header can be included without needing additional dependencies diff --git a/test/lock/LockPoolIncludeTest.cpp b/test/cpp-utils/lock/LockPoolIncludeTest.cpp similarity index 60% rename from test/lock/LockPoolIncludeTest.cpp rename to test/cpp-utils/lock/LockPoolIncludeTest.cpp index 8080947f..31d1406d 100644 --- a/test/lock/LockPoolIncludeTest.cpp +++ b/test/cpp-utils/lock/LockPoolIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/lock/LockPool.h" +#include "../../../src/cpp-utils/lock/LockPool.h" // Test the header can be included without needing additional dependencies diff --git a/test/lock/MutexPoolLockIncludeTest.cpp b/test/cpp-utils/lock/MutexPoolLockIncludeTest.cpp similarity index 58% rename from test/lock/MutexPoolLockIncludeTest.cpp rename to test/cpp-utils/lock/MutexPoolLockIncludeTest.cpp index 78c19620..35e8eb07 100644 --- a/test/lock/MutexPoolLockIncludeTest.cpp +++ b/test/cpp-utils/lock/MutexPoolLockIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/lock/MutexPoolLock.h" +#include "../../../src/cpp-utils/lock/MutexPoolLock.h" // Test the header can be included without needing additional dependencies diff --git a/test/logging/LoggerIncludeTest.cpp b/test/cpp-utils/logging/LoggerIncludeTest.cpp similarity index 59% rename from test/logging/LoggerIncludeTest.cpp rename to test/cpp-utils/logging/LoggerIncludeTest.cpp index 40ebe722..7b07ca4c 100644 --- a/test/logging/LoggerIncludeTest.cpp +++ b/test/cpp-utils/logging/LoggerIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/logging/Logger.h" +#include "../../../src/cpp-utils/logging/Logger.h" // Test the header can be included without needing additional dependencies diff --git a/test/logging/LoggerTest.cpp b/test/cpp-utils/logging/LoggerTest.cpp similarity index 100% rename from test/logging/LoggerTest.cpp rename to test/cpp-utils/logging/LoggerTest.cpp diff --git a/test/logging/LoggingIncludeTest.cpp b/test/cpp-utils/logging/LoggingIncludeTest.cpp similarity index 59% rename from test/logging/LoggingIncludeTest.cpp rename to test/cpp-utils/logging/LoggingIncludeTest.cpp index 8bc3c8b7..9300fe80 100644 --- a/test/logging/LoggingIncludeTest.cpp +++ b/test/cpp-utils/logging/LoggingIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/logging/logging.h" +#include "../../../src/cpp-utils/logging/logging.h" // Test the header can be included without needing additional dependencies diff --git a/test/logging/LoggingLevelTest.cpp b/test/cpp-utils/logging/LoggingLevelTest.cpp similarity index 100% rename from test/logging/LoggingLevelTest.cpp rename to test/cpp-utils/logging/LoggingLevelTest.cpp diff --git a/test/logging/LoggingTest.cpp b/test/cpp-utils/logging/LoggingTest.cpp similarity index 100% rename from test/logging/LoggingTest.cpp rename to test/cpp-utils/logging/LoggingTest.cpp diff --git a/test/logging/testutils/LoggingTest.h b/test/cpp-utils/logging/testutils/LoggingTest.h similarity index 95% rename from test/logging/testutils/LoggingTest.h rename to test/cpp-utils/logging/testutils/LoggingTest.h index 2bfef9f3..5c8f5269 100644 --- a/test/logging/testutils/LoggingTest.h +++ b/test/cpp-utils/logging/testutils/LoggingTest.h @@ -4,7 +4,7 @@ #include #include -#include "../../../src/logging/logging.h" +#include "../../../../src/cpp-utils/logging/logging.h" class MockLogger final { public: diff --git a/test/network/CurlHttpClientTest.cpp b/test/cpp-utils/network/CurlHttpClientTest.cpp similarity index 85% rename from test/network/CurlHttpClientTest.cpp rename to test/cpp-utils/network/CurlHttpClientTest.cpp index f701a76f..54abbdc9 100644 --- a/test/network/CurlHttpClientTest.cpp +++ b/test/cpp-utils/network/CurlHttpClientTest.cpp @@ -1,7 +1,7 @@ #include #include -#include "../../src/network/CurlHttpClient.h" -#include "../../src/pointer/unique_ref_boost_optional_gtest_workaround.h" +#include "../../../src/cpp-utils/network/CurlHttpClient.h" +#include "../../../src/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h" using std::string; using boost::none; diff --git a/test/network/FakeHttpClientTest.cpp b/test/cpp-utils/network/FakeHttpClientTest.cpp similarity index 89% rename from test/network/FakeHttpClientTest.cpp rename to test/cpp-utils/network/FakeHttpClientTest.cpp index 3fdd2e2e..1c69f073 100644 --- a/test/network/FakeHttpClientTest.cpp +++ b/test/cpp-utils/network/FakeHttpClientTest.cpp @@ -1,6 +1,6 @@ #include -#include "../../src/network/FakeHttpClient.h" -#include "../../src/pointer/unique_ref_boost_optional_gtest_workaround.h" +#include "../../../src/cpp-utils/network/FakeHttpClient.h" +#include "../../../src/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h" using boost::none; diff --git a/test/pointer/cast_include_test.cpp b/test/cpp-utils/pointer/cast_include_test.cpp similarity index 60% rename from test/pointer/cast_include_test.cpp rename to test/cpp-utils/pointer/cast_include_test.cpp index 7bce8de5..ad7a24e0 100644 --- a/test/pointer/cast_include_test.cpp +++ b/test/cpp-utils/pointer/cast_include_test.cpp @@ -1,3 +1,3 @@ -#include "../../src/pointer/cast.h" +#include "../../../src/cpp-utils/pointer/cast.h" // Test the header can be included without needing additional dependencies diff --git a/test/pointer/cast_test.cpp b/test/cpp-utils/pointer/cast_test.cpp similarity index 97% rename from test/pointer/cast_test.cpp rename to test/cpp-utils/pointer/cast_test.cpp index b6ce2e16..b2aa220e 100644 --- a/test/pointer/cast_test.cpp +++ b/test/cpp-utils/pointer/cast_test.cpp @@ -1,8 +1,8 @@ #include #include -#include "../../src/pointer/cast.h" -#include "../../src/pointer/unique_ref.h" -#include "../../src/pointer/unique_ref_boost_optional_gtest_workaround.h" +#include "../../../src/cpp-utils/pointer/cast.h" +#include "../../../src/cpp-utils/pointer/unique_ref.h" +#include "../../../src/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h" //TODO There is a lot of duplication here, because each test case is there twice - once for unique_ptr, once for unique_ref. Remove redundancy by using generic test cases. //TODO Then also move the unique_ref related test cases there - cast_test.cpp should only contain the unique_ptr related ones. diff --git a/test/pointer/optional_ownership_ptr_include_test.cpp b/test/cpp-utils/pointer/optional_ownership_ptr_include_test.cpp similarity index 53% rename from test/pointer/optional_ownership_ptr_include_test.cpp rename to test/cpp-utils/pointer/optional_ownership_ptr_include_test.cpp index b9e3da18..dd6a4dfa 100644 --- a/test/pointer/optional_ownership_ptr_include_test.cpp +++ b/test/cpp-utils/pointer/optional_ownership_ptr_include_test.cpp @@ -1,3 +1,3 @@ -#include "../../src/pointer/optional_ownership_ptr.h" +#include "../../../src/cpp-utils/pointer/optional_ownership_ptr.h" // Test the header can be included without needing additional dependencies diff --git a/test/pointer/optional_ownership_ptr_test.cpp b/test/cpp-utils/pointer/optional_ownership_ptr_test.cpp similarity index 96% rename from test/pointer/optional_ownership_ptr_test.cpp rename to test/cpp-utils/pointer/optional_ownership_ptr_test.cpp index 4f97a193..c6950cc2 100644 --- a/test/pointer/optional_ownership_ptr_test.cpp +++ b/test/cpp-utils/pointer/optional_ownership_ptr_test.cpp @@ -1,6 +1,6 @@ #include -#include "../../src/pointer/optional_ownership_ptr.h" -#include "../../src/macros.h" +#include "../../../src/cpp-utils/pointer/optional_ownership_ptr.h" +#include "../../../src/cpp-utils/macros.h" using std::unique_ptr; using std::function; diff --git a/test/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp b/test/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp new file mode 100644 index 00000000..3aa6f9c9 --- /dev/null +++ b/test/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp @@ -0,0 +1,3 @@ +#include "../../../src/cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h" + +// Test the header can be included without needing additional dependencies diff --git a/test/pointer/unique_ref_include_test.cpp b/test/cpp-utils/pointer/unique_ref_include_test.cpp similarity index 58% rename from test/pointer/unique_ref_include_test.cpp rename to test/cpp-utils/pointer/unique_ref_include_test.cpp index f8372d06..5679f675 100644 --- a/test/pointer/unique_ref_include_test.cpp +++ b/test/cpp-utils/pointer/unique_ref_include_test.cpp @@ -1,3 +1,3 @@ -#include "../../src/pointer/unique_ref.h" +#include "../../../src/cpp-utils/pointer/unique_ref.h" // Test the header can be included without needing additional dependencies diff --git a/test/pointer/unique_ref_test.cpp b/test/cpp-utils/pointer/unique_ref_test.cpp similarity index 99% rename from test/pointer/unique_ref_test.cpp rename to test/cpp-utils/pointer/unique_ref_test.cpp index 2e9d038e..88e0ab97 100644 --- a/test/pointer/unique_ref_test.cpp +++ b/test/cpp-utils/pointer/unique_ref_test.cpp @@ -1,5 +1,5 @@ #include -#include "../../src/pointer/unique_ref.h" +#include "../../../src/cpp-utils/pointer/unique_ref.h" #include #include #include diff --git a/test/process/daemonize_include_test.cpp b/test/cpp-utils/process/daemonize_include_test.cpp similarity index 58% rename from test/process/daemonize_include_test.cpp rename to test/cpp-utils/process/daemonize_include_test.cpp index 51897d79..3074d294 100644 --- a/test/process/daemonize_include_test.cpp +++ b/test/cpp-utils/process/daemonize_include_test.cpp @@ -1,4 +1,4 @@ -#include "../../src/process/daemonize.h" +#include "../../../src/cpp-utils/process/daemonize.h" // Test the header can be included without needing additional dependencies diff --git a/test/process/subprocess_include_test.cpp b/test/cpp-utils/process/subprocess_include_test.cpp similarity index 58% rename from test/process/subprocess_include_test.cpp rename to test/cpp-utils/process/subprocess_include_test.cpp index f44da2a5..9d412eb7 100644 --- a/test/process/subprocess_include_test.cpp +++ b/test/cpp-utils/process/subprocess_include_test.cpp @@ -1,4 +1,4 @@ -#include "../../src/process/subprocess.h" +#include "../../../src/cpp-utils/process/subprocess.h" // Test the header can be included without needing additional dependencies diff --git a/test/random/RandomIncludeTest.cpp b/test/cpp-utils/random/RandomIncludeTest.cpp similarity index 60% rename from test/random/RandomIncludeTest.cpp rename to test/cpp-utils/random/RandomIncludeTest.cpp index 5638f7fa..3c69cab5 100644 --- a/test/random/RandomIncludeTest.cpp +++ b/test/cpp-utils/random/RandomIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/random/Random.h" +#include "../../../src/cpp-utils/random/Random.h" // Test the header can be included without needing additional dependencies diff --git a/test/tempfile/TempDirIncludeTest.cpp b/test/cpp-utils/tempfile/TempDirIncludeTest.cpp similarity index 58% rename from test/tempfile/TempDirIncludeTest.cpp rename to test/cpp-utils/tempfile/TempDirIncludeTest.cpp index d121b2b0..75783fd1 100644 --- a/test/tempfile/TempDirIncludeTest.cpp +++ b/test/cpp-utils/tempfile/TempDirIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/tempfile/TempDir.h" +#include "../../../src/cpp-utils/tempfile/TempDir.h" // Test the header can be included without needing additional dependencies diff --git a/test/tempfile/TempDirTest.cpp b/test/cpp-utils/tempfile/TempDirTest.cpp similarity index 95% rename from test/tempfile/TempDirTest.cpp rename to test/cpp-utils/tempfile/TempDirTest.cpp index 8e62b2fc..417dfbfc 100644 --- a/test/tempfile/TempDirTest.cpp +++ b/test/cpp-utils/tempfile/TempDirTest.cpp @@ -1,6 +1,6 @@ #include -#include "../../src/tempfile/TempDir.h" +#include "../../../src/cpp-utils/tempfile/TempDir.h" #include diff --git a/test/tempfile/TempFileIncludeTest.cpp b/test/cpp-utils/tempfile/TempFileIncludeTest.cpp similarity index 58% rename from test/tempfile/TempFileIncludeTest.cpp rename to test/cpp-utils/tempfile/TempFileIncludeTest.cpp index 890804e6..75f3f9d8 100644 --- a/test/tempfile/TempFileIncludeTest.cpp +++ b/test/cpp-utils/tempfile/TempFileIncludeTest.cpp @@ -1,3 +1,3 @@ -#include "../../src/tempfile/TempFile.h" +#include "../../../src/cpp-utils/tempfile/TempFile.h" // Test the header can be included without needing additional dependencies diff --git a/test/tempfile/TempFileTest.cpp b/test/cpp-utils/tempfile/TempFileTest.cpp similarity index 96% rename from test/tempfile/TempFileTest.cpp rename to test/cpp-utils/tempfile/TempFileTest.cpp index e64be148..c3a1959c 100644 --- a/test/tempfile/TempFileTest.cpp +++ b/test/cpp-utils/tempfile/TempFileTest.cpp @@ -1,7 +1,7 @@ #include -#include "../../src/tempfile/TempFile.h" -#include "../../src/tempfile/TempDir.h" +#include "../../../src/cpp-utils/tempfile/TempFile.h" +#include "../../../src/cpp-utils/tempfile/TempDir.h" #include diff --git a/test/pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp b/test/pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp deleted file mode 100644 index fd2a50be..00000000 --- a/test/pointer/unique_ref_boost_optional_gtest_workaround_include_test.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "../../src/pointer/unique_ref_boost_optional_gtest_workaround.h" - -// Test the header can be included without needing additional dependencies diff --git a/utils.cmake b/utils.cmake new file mode 100644 index 00000000..b5cc1408 --- /dev/null +++ b/utils.cmake @@ -0,0 +1,47 @@ +################################################### +# Activate C++14 +# +# Uses: ACTIVATE_CPP14(buildtarget) +################################################### +function(ACTIVATE_CPP14 TARGET) + CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_HAS_CPP14_SUPPORT) + IF (COMPILER_HAS_CPP14_SUPPORT) + TARGET_COMPILE_OPTIONS(${TARGET} PUBLIC -std=c++14) + ELSE() + CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_HAS_CPP14_PARTIAL_SUPPORT) + IF (COMPILER_HAS_CPP14_PARTIAL_SUPPORT) + TARGET_COMPILE_OPTIONS(${TARGET} PUBLIC -std=c++1y) + ELSE() + MESSAGE(FATAL_ERROR "Compiler doesn't support C++14") + ENDIF() + ENDIF() + IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + TARGET_COMPILE_OPTIONS(${TARGET} PUBLIC -stdlib=libc++) + ENDIF() +endfunction(ACTIVATE_CPP14) + +################################################# +# Enable style compiler warnings +# +# Uses: ENABLE_STYLE_WARNINGS(buildtarget) +################################################# +function(ENABLE_STYLE_WARNINGS TARGET) + TARGET_COMPILE_OPTIONS(${TARGET} PRIVATE -Wall -Wextra) +endfunction(ENABLE_STYLE_WARNINGS) + +################################################## +# Add boost to the project +# +# Uses: +# ADD_BOOST(buildtarget) # if you're only using header-only boost libs +# ADD_BOOST(buildtarget system filesystem) # list all libraries to link against in the dependencies +################################################## +function(ADD_BOOST TARGET) + # Load boost libraries + find_package(Boost 1.56.0 + REQUIRED + COMPONENTS ${ARGN}) + set(Boost_USE_STATIC_LIBS ON) + target_include_directories(${TARGET} SYSTEM PRIVATE ${Boost_INCLUDE_DIRS}) + target_link_libraries(${TARGET} PRIVATE ${Boost_LIBRARIES}) +endfunction()