Skip to content

Commit

Permalink
Set CMake and Travis CI up.
Browse files Browse the repository at this point in the history
* Set CMake and Travis CI.

* Fix an issue and naming and line break conventions.
  • Loading branch information
IYP-Programer-Yeah authored Mar 9, 2019
1 parent f46441f commit 061c777
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 33 deletions.
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: cpp
compiler:
- gcc-5
os:
- linux

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-5
- g++-5

script:
- mkdir Projects/CMake/Build -p
- cd Projects/CMake/Build
- export CC=gcc-5
- export CXX=g++-5
- cmake --version
- cmake .. -DCMAKE_INSTALL_PREFIX:PATH=./Artifact
- make
- make install
- ./Artifact/bin/Test
after_success:
11 changes: 7 additions & 4 deletions Messenger/Include/messenger.inl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Messenger
public:

// If the module has the proper message processor, this value will be true, otherwise this will be false.
static constexpr bool value = std::is_same<std::true_type, decltype(test_processor_method<MOT>(nullptr))>::value;
static constexpr bool Value = std::is_same<std::true_type, decltype(test_processor_method<MOT>(nullptr))>::value;
};

// Pass a single message to a single module if the module has proper message processor.
Expand Down Expand Up @@ -88,7 +88,7 @@ namespace Messenger
template <typename ModuleType>
CPP_14_CONSTEXPR void operator()(ModuleType& module) const
{
DoMessageProcessor<HasMessageProcessor<ModuleType, MessageType>::value, HasMessageProcessor<ModuleType, MessengerType, MessageType>::value>::process_message(module, messenger, message);
DoMessageProcessor<HasMessageProcessor<ModuleType, MessageType>::Value, HasMessageProcessor<ModuleType, MessengerType, MessageType>::Value>::process_message(module, messenger, message);
}

const MessengerType &messenger;
Expand All @@ -106,7 +106,7 @@ namespace Messenger
public:

// The count of modules in messenger.
static constexpr std::size_t module_count = sizeof... (Modules);
static constexpr std::size_t ModuleCount = sizeof... (Modules);

template <typename Message>
CPP_14_CONSTEXPR void operator()(const Message& message) const
Expand Down Expand Up @@ -145,10 +145,13 @@ namespace Messenger
}
};

template<typename... Modules>
constexpr typename std::size_t MessengerImpl<Modules...>::ModuleCount;

template <typename... Modules>
struct Messenger : private MessengerImpl<Modules...>
{
using MessengerImpl<Modules...>::module_count;
using MessengerImpl<Modules...>::ModuleCount;
using MessengerImpl<Modules...>::pass_message;
using MessengerImpl<Modules...>::get_module;
};
Expand Down
17 changes: 17 additions & 0 deletions Projects/CMake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required (VERSION 3.5)

set(REPO_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
set(CMAKE_PROJECT_ROOT ${REPO_ROOT}/Projects/CMake)
set(LOCAL_BUILD_DIR ${CMAKE_PROJECT_ROOT}/Build)
if(WIN32)
set(LOCAL_INCLUDE_DIR ${LOCAL_BUILD_DIR}/Include)
else()
set(LOCAL_INCLUDE_DIR ${LOCAL_BUILD_DIR}/include)
endif()
set(CMAKE_CXX_STANDARD 11)

add_subdirectory(Utility)
add_subdirectory(googletest)
add_subdirectory(MDP)
add_subdirectory(Test)

16 changes: 16 additions & 0 deletions Projects/CMake/MDP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
project(MDP)

add_custom_target(${PROJECT_NAME}_HEADERS ALL
${CMAKE_COMMAND} -E make_directory ${LOCAL_INCLUDE_DIR}/${PROJECT_NAME}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${REPO_ROOT}/Messenger/Include/ ${LOCAL_INCLUDE_DIR}/${PROJECT_NAME})

add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE ${LOCAL_INCLUDE_DIR})
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_HEADERS)

if(WIN32)
install(DIRECTORY ${REPO_ROOT}/Messenger/Include/ DESTINATION Include/${PROJECT_NAME})
else()
install(DIRECTORY ${REPO_ROOT}/Messenger/Include/ DESTINATION include/${PROJECT_NAME})
endif()

24 changes: 24 additions & 0 deletions Projects/CMake/Test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
project(Test CXX)

include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include_directories(${LOCAL_INCLUDE_DIR})

file(GLOB CPP_FILES ${REPO_ROOT}/${PROJECT_NAME}/Source/*.cpp)
add_executable(${PROJECT_NAME} ${CPP_FILES})
target_link_libraries(${PROJECT_NAME} gtest gtest_main MDP Utility)

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")

if(WIN32)
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION Lib
RUNTIME DESTINATION Bin
ARCHIVE DESTINATION Lib)
else()
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib)
endif()

2 changes: 2 additions & 0 deletions Projects/CMake/Utility/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(REPO_ROOT ${REPO_ROOT}/Dependencies/Utility/)
add_subdirectory(${REPO_ROOT}/Projects/CMake/Utility Utility)
1 change: 1 addition & 0 deletions Projects/CMake/googletest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(${REPO_ROOT}/Dependencies/googletest/googletest/ gtest)
56 changes: 28 additions & 28 deletions Test/Source/has-message-processor-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,195 +109,195 @@ using MessengerType = Messenger::Messenger<HasProperMessageProcessor, HasNoPrope
// Test#0 No proper message processor.
TEST(HasMessageProcessorTest, NO_PROCESSOR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<0>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<0>>::Value;
EXPECT_EQ(Result, false);
}

// Test#1
TEST(HasMessageProcessorTest, CR_NONE_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<1>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<1>>::Value;
EXPECT_EQ(Result, true);
}

// Test#2
TEST(HasMessageProcessorTest, CC_NONE_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<2>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<2>>::Value;
EXPECT_EQ(Result, true);
}

// Test#3
TEST(HasMessageProcessorTest, CTR_NONE_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<3>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<3>>::Value;
EXPECT_EQ(Result, true);
}

// Test#4
TEST(HasMessageProcessorTest, CTC_NONE_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<4>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<4>>::Value;
EXPECT_EQ(Result, true);
}

// Test#5
TEST(HasMessageProcessorTest, UR_NONE_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<5>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<5>>::Value;
EXPECT_EQ(Result, true);
}

// Test#6
TEST(HasMessageProcessorTest, CR_CR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<6>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<6>>::Value;
EXPECT_EQ(Result, true);
}

// Test#7
TEST(HasMessageProcessorTest, CC_CR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<7>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<7>>::Value;
EXPECT_EQ(Result, true);
}

// Test#8
TEST(HasMessageProcessorTest, CTR_CR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<8>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<8>>::Value;
EXPECT_EQ(Result, true);
}

// Test#9
TEST(HasMessageProcessorTest, CTC_CR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<9>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<9>>::Value;
EXPECT_EQ(Result, true);
}

// Test#10
TEST(HasMessageProcessorTest, UR_CR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<10>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<10>>::Value;
EXPECT_EQ(Result, true);
}

// Test#11
TEST(HasMessageProcessorTest, CR_CC_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<11>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<11>>::Value;
EXPECT_EQ(Result, true);
}

// Test#12
TEST(HasMessageProcessorTest, CC_CC_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<12>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<12>>::Value;
EXPECT_EQ(Result, true);
}

// Test#13
TEST(HasMessageProcessorTest, CTR_CC_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<13>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<13>>::Value;
EXPECT_EQ(Result, true);
}

// Test#14
TEST(HasMessageProcessorTest, CTC_CC_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<14>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<14>>::Value;
EXPECT_EQ(Result, true);
}

// Test#15
TEST(HasMessageProcessorTest, UR_CC_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<15>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<15>>::Value;
EXPECT_EQ(Result, true);
}

// Test#16
TEST(HasMessageProcessorTest, CR_UR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<16>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<16>>::Value;
EXPECT_EQ(Result, true);
}

// Test#17
TEST(HasMessageProcessorTest, CC_UR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<17>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<17>>::Value;
EXPECT_EQ(Result, true);
}

// Test#18
TEST(HasMessageProcessorTest, CTR_UR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<18>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<18>>::Value;
EXPECT_EQ(Result, true);
}

// Test#19
TEST(HasMessageProcessorTest, CTC_UR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<19>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<19>>::Value;
EXPECT_EQ(Result, true);
}

// Test#20
TEST(HasMessageProcessorTest, UR_UR_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<20>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessengerType, MessageType<20>>::Value;
EXPECT_EQ(Result, true);
}

// Test#21
TEST(HasMessageProcessorTest, BAD_RETURN_TYPE_NONE_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<21>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<21>>::Value;
EXPECT_EQ(Result, false);
}

// Test#22
TEST(HasMessageProcessorTest, NON_CONST_REF_MESSAGE_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<22>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<22>>::Value;
EXPECT_EQ(Result, false);
}

// Test#23
TEST(HasMessageProcessorTest, WORNG_MESSAGE_TYPE_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<23>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<23>>::Value;
EXPECT_EQ(Result, false);
}

// Test#24
TEST(HasMessageProcessorTest, NON_CONST_REF_MESSAGE_CORRECT_MESSENGER_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<24>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<24>>::Value;
EXPECT_EQ(Result, false);
}

// Test#25
TEST(HasMessageProcessorTest, CORRECT_NON_CONST_REF_MESSENGER_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<25>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<25>>::Value;
EXPECT_EQ(Result, false);
}

// Test#26
TEST(HasMessageProcessorTest, WRONG_MESSAGE_TYPE_CORRECT_MESSENGER_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<26>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<26>>::Value;
EXPECT_EQ(Result, false);
}

// Test#27
TEST(HasMessageProcessorTest, CORRECT_MESSAGE_WRONG_MESSENGER_TYPE_TEST)
{
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<27>>::value;
constexpr bool Result = Messenger::Private::HasMessageProcessor<HasProperMessageProcessor, MessageType<27>>::Value;
EXPECT_EQ(Result, false);
}
2 changes: 1 addition & 1 deletion Test/Source/messenger-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ using MessengerType = Messenger::Messenger<MessengerModule<0>, MessengerModule<1

TEST(MessengerTest, ModuleCountTest)
{
EXPECT_EQ(MessengerType::module_count, 4);
EXPECT_EQ(MessengerType::ModuleCount, 4);
}

TEST(MessengerTest, GetModuleTest)
Expand Down

0 comments on commit 061c777

Please sign in to comment.