feat add move_on_copy
Some checks failed
linux-arm-gcc / linux-gcc-arm (push) Failing after 2m27s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 1m42s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 2m22s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m50s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 2m40s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 2m13s
Some checks failed
linux-arm-gcc / linux-gcc-arm (push) Failing after 2m27s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 1m42s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 2m22s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m50s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 2m40s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 2m13s
This commit is contained in:
parent
ed3fa45a36
commit
27ebd0d420
@ -43,8 +43,8 @@ jobs:
|
||||
- name: install-qemu-build-deps
|
||||
if: steps.cache-qemu.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install autoconf automake autotools-dev ninja-build
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y autoconf automake autotools-dev ninja-build
|
||||
- name: checkout-qemu
|
||||
if: steps.cache-qemu.outputs.cache-hit != 'true'
|
||||
uses: actions/checkout@v4
|
||||
@ -62,8 +62,8 @@ jobs:
|
||||
|
||||
- name: arm-gnu-toolchain
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install g++-arm-linux-gnueabi
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y g++-arm-linux-gnueabi
|
||||
|
||||
- name: build
|
||||
run: |
|
||||
@ -90,8 +90,8 @@ jobs:
|
||||
- name: install-qemu-build-deps
|
||||
if: steps.cache-qemu.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install autoconf automake autotools-dev ninja-build
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y autoconf automake autotools-dev ninja-build
|
||||
- name: checkout-qemu
|
||||
if: steps.cache-qemu.outputs.cache-hit != 'true'
|
||||
uses: actions/checkout@v4
|
||||
@ -109,8 +109,8 @@ jobs:
|
||||
|
||||
- name: arm-gnu-toolchain
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install g++-arm-linux-gnueabihf
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y g++-arm-linux-gnueabihf
|
||||
|
||||
- name: build
|
||||
run: |
|
||||
|
@ -98,10 +98,9 @@ target_sources(
|
||||
target_link_libraries(
|
||||
sled
|
||||
PUBLIC rpc_core fmt marl Async++ minilua
|
||||
PRIVATE dl
|
||||
PRIVATE dl
|
||||
# protobuf::libprotobuf ${WHOLE_ARCHIVE_WRAPPER_START}
|
||||
# tcmalloc_and_profiler_static
|
||||
# ${WHOLE_ARCHIVE_WRAPPER_END}
|
||||
# tcmalloc_and_profiler_static ${WHOLE_ARCHIVE_WRAPPER_END}
|
||||
)
|
||||
|
||||
# set fPIC
|
||||
@ -126,7 +125,7 @@ endif(SLED_BUILD_BENCHMARK)
|
||||
|
||||
function(sled_add_test)
|
||||
set(prefix SLED_TEST)
|
||||
# set(options INC_DIRS LIBS)
|
||||
set(options NO_MAIN)
|
||||
set(one_value_keywords NAME)
|
||||
set(multi_value_keywords SRCS INC_DIRS LIBS)
|
||||
cmake_parse_arguments("${prefix}" "${options}" "${one_value_keywords}"
|
||||
@ -148,7 +147,9 @@ function(sled_add_test)
|
||||
sled/testing/test.h)
|
||||
endif()
|
||||
target_include_directories(${SLED_TEST_NAME} PRIVATE ${SLED_TEST_INC_DIRS})
|
||||
target_link_libraries(${SLED_TEST_NAME} PRIVATE ${SLED_TEST_LIBS} sled)
|
||||
target_link_libraries(
|
||||
${SLED_TEST_NAME} PRIVATE ${SLED_TEST_LIBS} sled $<$<BOOL: NOT
|
||||
${SLED_TEST_NO_MAIN}>:test_main>)
|
||||
add_test(NAME ${SLED_TEST_NAME} COMMAND ${SLED_TEST_NAME})
|
||||
endfunction()
|
||||
|
||||
@ -176,13 +177,13 @@ if(SLED_BUILD_TESTS)
|
||||
src/sled/system/fiber/fiber_test.cc
|
||||
src/sled/system/thread_pool_test.cc
|
||||
src/sled/rx_test.cc
|
||||
src/sled/uri_test.cc
|
||||
LIBS
|
||||
test_main)
|
||||
src/sled/uri_test.cc)
|
||||
|
||||
sled_add_test(NAME sled_symbolize_test SRCS
|
||||
src/sled/debugging/symbolize_test.cc)
|
||||
sled_add_test(NAME sled_lua_test SRCS tests/lua_test.cc LIBS test_main)
|
||||
src/sled/debugging/symbolize_test.cc NO_MAIN)
|
||||
sled_add_test(NAME sled_lua_test SRCS tests/lua_test.cc)
|
||||
sled_add_test(NAME sled_move_on_copy_test SRCS
|
||||
src/sled/utility/move_on_copy_test.cc)
|
||||
endif(SLED_BUILD_TESTS)
|
||||
|
||||
if(SLED_BUILD_FUZZ)
|
||||
|
@ -62,6 +62,9 @@ namespace async {}
|
||||
#include "sled/timer/timeout.h"
|
||||
#include "sled/timer/timer.h"
|
||||
|
||||
// utility
|
||||
#include "sled/utility/move_on_copy.h"
|
||||
|
||||
// other
|
||||
#include "sled/any.h"
|
||||
#include "sled/apply.h"
|
||||
@ -91,4 +94,5 @@ namespace async {}
|
||||
|
||||
// testing
|
||||
#include "sled/testing/test.h"
|
||||
// debugging
|
||||
#endif// SLED_SLED_H
|
||||
|
@ -25,7 +25,8 @@ template<typename T>
|
||||
auto
|
||||
MakeMoveOnCopy(T &&value) -> MoveOnCopy<T>
|
||||
{
|
||||
return {std::move<T>(value)};
|
||||
return {std::move(value)};
|
||||
}
|
||||
|
||||
}// namespace sled
|
||||
#endif// SLED_UTILITY_MOVE_ON_COPY_H
|
||||
|
43
src/sled/utility/move_on_copy_test.cc
Normal file
43
src/sled/utility/move_on_copy_test.cc
Normal file
@ -0,0 +1,43 @@
|
||||
#include <sled/utility/move_on_copy.h>
|
||||
|
||||
TEST_SUITE("MoveOnCopy")
|
||||
{
|
||||
TEST_CASE("Constructor imm value")
|
||||
{
|
||||
// immediately value
|
||||
sled::MoveOnCopy<int> m(1);
|
||||
|
||||
auto m_copy = m;
|
||||
CHECK_EQ(m_copy.value, 1);
|
||||
}
|
||||
TEST_CASE("Constructor implicit convert")
|
||||
{
|
||||
sled::MoveOnCopy<std::string> from_str("test");
|
||||
auto from_str_copy = from_str;
|
||||
CHECK_EQ(from_str_copy.value, "test");
|
||||
CHECK_EQ(from_str.value, "");
|
||||
}
|
||||
|
||||
TEST_CASE("Constructor from rvalue")
|
||||
{
|
||||
sled::MoveOnCopy<std::string> from_rvalue_std_string(std::move(std::string("test")));
|
||||
auto from_rvalue_std_string_copy = from_rvalue_std_string;
|
||||
CHECK_EQ(from_rvalue_std_string_copy.value, "test");
|
||||
CHECK_EQ(from_rvalue_std_string.value, "");
|
||||
}
|
||||
TEST_CASE("Constructor(&&)")
|
||||
{
|
||||
sled::MoveOnCopy<std::string> from_rvalue_std_string(std::move(std::string("test")));
|
||||
sled::MoveOnCopy<std::string> from_rvalue_std_string_copy(std::move(from_rvalue_std_string));
|
||||
CHECK_EQ(from_rvalue_std_string_copy.value, "test");
|
||||
CHECK_EQ(from_rvalue_std_string.value, "");
|
||||
}
|
||||
|
||||
TEST_CASE("MakeMoveOnCopy")
|
||||
{
|
||||
auto m = sled::MakeMoveOnCopy(std::move(std::string("test")));
|
||||
auto m_copy = m;
|
||||
CHECK_EQ(m_copy.value, "test");
|
||||
CHECK_EQ(m.value, "");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user