feat add EventBus
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Failing after 10s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Failing after 10s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Failing after 10s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Failing after 10s
linux-x64-gcc / linux-gcc (push) Failing after 14s
linux-mips64-gcc / linux-gcc-mips64el (push) Failing after 20s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Failing after 22s
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Failing after 10s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Failing after 10s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Failing after 10s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Failing after 10s
linux-x64-gcc / linux-gcc (push) Failing after 14s
linux-mips64-gcc / linux-gcc-mips64el (push) Failing after 20s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Failing after 22s
This commit is contained in:
parent
30f46d994f
commit
d5ae2b9797
1
3party/EventBus
Submodule
1
3party/EventBus
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 62046399d423b74fd2612c85ef287bc6d309e0b4
|
@ -2500,7 +2500,7 @@ template<typename T>
|
|||||||
using hash = std::hash<tl::optional<T>>;
|
using hash = std::hash<tl::optional<T>>;
|
||||||
|
|
||||||
// if <= C++14
|
// if <= C++14
|
||||||
#if __cplusplus < 201703L
|
// #if __cplusplus < 201703L
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using optional = tl::optional<T>;
|
using optional = tl::optional<T>;
|
||||||
|
|
||||||
@ -2530,7 +2530,7 @@ make_optional(std::initializer_list<U> il, Args &&...args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
constexpr tl::nullopt_t nullopt{tl::nullopt};
|
constexpr tl::nullopt_t nullopt{tl::nullopt};
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
}// namespace ulib
|
}// namespace ulib
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,17 +16,17 @@ option(ULIB_SHARED_LIB "Build shared library" OFF)
|
|||||||
option(ULIB_BUILD_EXAMPLES "Build examples" OFF)
|
option(ULIB_BUILD_EXAMPLES "Build examples" OFF)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "Release")
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
# set stripped
|
# set stripped
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
|
||||||
endif()
|
endif()
|
||||||
# add -static-libgcc and -static-libstdc++ to link flags
|
# add -static-libgcc and -static-libstdc++ to link flags
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
if(ULIB_SHARED_LIB)
|
if(ULIB_SHARED_LIB)
|
||||||
add_library(${PROJECT_NAME} SHARED "")
|
add_library(${PROJECT_NAME} SHARED "")
|
||||||
else()
|
else()
|
||||||
add_library(${PROJECT_NAME} STATIC "" src/ulib/system/timer.cpp
|
add_library(${PROJECT_NAME} STATIC "" src/ulib/system/timer.cpp
|
||||||
src/ulib/system/timer.h)
|
src/ulib/system/timer.h)
|
||||||
endif()
|
endif()
|
||||||
target_sources(
|
target_sources(
|
||||||
@ -63,10 +63,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|||||||
|
|
||||||
# CMP0063
|
# CMP0063
|
||||||
if(POLICY CMP0063)
|
if(POLICY CMP0063)
|
||||||
cmake_policy(SET CMP0063 NEW)
|
cmake_policy(SET CMP0063 NEW)
|
||||||
endif()
|
endif()
|
||||||
if(POLICY CMP0048)
|
if(POLICY CMP0048)
|
||||||
cmake_policy(SET CMP0048 NEW)
|
cmake_policy(SET CMP0048 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(FMT_USE_CPP11
|
set(FMT_USE_CPP11
|
||||||
@ -80,6 +80,8 @@ set(FMT_USE_CPP11
|
|||||||
CACHE BOOL "Use C++11" FORCE)
|
CACHE BOOL "Use C++11" FORCE)
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3party/fmt)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3party/fmt)
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3party/sqlpp11)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3party/sqlpp11)
|
||||||
|
set(ENABLE_TEST OFF)
|
||||||
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3party/EventBus)
|
||||||
|
|
||||||
set(JSONCPP_WITH_TESTS OFF)
|
set(JSONCPP_WITH_TESTS OFF)
|
||||||
set(JSONCPP_WITH_POST_BUILD_UNITTEST OFF)
|
set(JSONCPP_WITH_POST_BUILD_UNITTEST OFF)
|
||||||
@ -92,7 +94,7 @@ target_sources(
|
|||||||
${PROJECT_NAME} PRIVATE src/ulib/empty.cpp src/ulib/log/logger.cpp
|
${PROJECT_NAME} PRIVATE src/ulib/empty.cpp src/ulib/log/logger.cpp
|
||||||
src/ulib/log/log.cpp src/ulib/log/level.cpp)
|
src/ulib/log/log.cpp src/ulib/log/level.cpp)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC fmt::fmt jsoncpp_static
|
target_link_libraries(${PROJECT_NAME} PUBLIC fmt::fmt jsoncpp_static
|
||||||
sqlpp11::sqlpp11)
|
sqlpp11::sqlpp11 Dexode::EventBus)
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE ULIB_LIBRARY_IMPL)
|
target_compile_definitions(${PROJECT_NAME} PRIVATE ULIB_LIBRARY_IMPL)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
@ -109,14 +111,14 @@ target_include_directories(
|
|||||||
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
|
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
|
||||||
|
|
||||||
if(ULIB_BUILD_TESTS)
|
if(ULIB_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
set(GTEST_LANG_CXX11 OFF)
|
set(GTEST_LANG_CXX11 OFF)
|
||||||
set(GTEST_HAS_TR1_TUPLE OFF)
|
set(GTEST_HAS_TR1_TUPLE OFF)
|
||||||
set(GTEST_USE_OWN_TR1_TUPLE ON)
|
set(GTEST_USE_OWN_TR1_TUPLE ON)
|
||||||
add_subdirectory(3party/googletest)
|
add_subdirectory(3party/googletest)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ULIB_BUILD_EXAMPLES)
|
if(ULIB_BUILD_EXAMPLES)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
endif()
|
endif()
|
||||||
|
22
tests/3party/EventBus/EventBus_unittest.cpp
Normal file
22
tests/3party/EventBus/EventBus_unittest.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <dexode/EventBus.hpp>
|
||||||
|
|
||||||
|
TEST(EventBus, BaseTest)
|
||||||
|
{
|
||||||
|
struct TestEvent {
|
||||||
|
int value;
|
||||||
|
};
|
||||||
|
|
||||||
|
dexode::EventBus bus;
|
||||||
|
auto listener = dexode::EventBus::Listener::createNotOwning(bus);
|
||||||
|
int callCount = 0;
|
||||||
|
{
|
||||||
|
listener.listen([&](const TestEvent &event) {
|
||||||
|
EXPECT_EQ(1, event.value);
|
||||||
|
++callCount;
|
||||||
|
});
|
||||||
|
bus.postpone(TestEvent{1});
|
||||||
|
EXPECT_EQ(bus.process(), 1);
|
||||||
|
EXPECT_EQ(callCount, 1);
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ add_executable(
|
|||||||
ulib/system/thread_unittest.cpp
|
ulib/system/thread_unittest.cpp
|
||||||
ulib/system/thread_pool_unittest.cpp
|
ulib/system/thread_pool_unittest.cpp
|
||||||
ulib/system/timer_unittest.cpp
|
ulib/system/timer_unittest.cpp
|
||||||
|
3party/EventBus/EventBus_unittest.cpp
|
||||||
3party/inja/inja_unittest.cpp
|
3party/inja/inja_unittest.cpp
|
||||||
3party/optional/optional_unittest.cpp
|
3party/optional/optional_unittest.cpp
|
||||||
3party/sqlpp11/sqlpp11_unittest.cpp
|
3party/sqlpp11/sqlpp11_unittest.cpp
|
||||||
|
Loading…
Reference in New Issue
Block a user