mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06:44 +08:00
Rename cti::expected -> cti::result
This commit is contained in:
parent
93b1d27b07
commit
ffa3b9ee1b
@ -35,8 +35,8 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <continuable/continuable-expected.hpp>
|
|
||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
|
#include <continuable/continuable-result.hpp>
|
||||||
#include <continuable/detail/connection/connection-all.hpp>
|
#include <continuable/detail/connection/connection-all.hpp>
|
||||||
#include <continuable/detail/connection/connection-any.hpp>
|
#include <continuable/detail/connection/connection-any.hpp>
|
||||||
#include <continuable/detail/connection/connection-seq.hpp>
|
#include <continuable/detail/connection/connection-seq.hpp>
|
||||||
@ -904,11 +904,11 @@ auto recover(Args&&... args) {
|
|||||||
|
|
||||||
inline auto rethrow(exception_t exception) {
|
inline auto rethrow(exception_t exception) {
|
||||||
// NOLINTNEXTLINE(hicpp-move-const-arg, performance-move-const-arg)
|
// NOLINTNEXTLINE(hicpp-move-const-arg, performance-move-const-arg)
|
||||||
return make_exceptional_expected(std::move(exception));
|
return make_exceptional_result(std::move(exception));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto cancel() {
|
inline auto cancel() {
|
||||||
return make_empty_expected();
|
return make_empty_result();
|
||||||
}
|
}
|
||||||
/// \}
|
/// \}
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|||||||
@ -28,41 +28,41 @@
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef CONTINUABLE_EXPECTED_HPP_INCLUDED
|
#ifndef CONTINUABLE_RESULT_HPP_INCLUDED
|
||||||
#define CONTINUABLE_EXPECTED_HPP_INCLUDED
|
#define CONTINUABLE_RESULT_HPP_INCLUDED
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
#include <continuable/detail/utility/expected-traits.hpp>
|
|
||||||
#include <continuable/detail/utility/flat-variant.hpp>
|
#include <continuable/detail/utility/flat-variant.hpp>
|
||||||
|
#include <continuable/detail/utility/result-trait.hpp>
|
||||||
#include <continuable/detail/utility/traits.hpp>
|
#include <continuable/detail/utility/traits.hpp>
|
||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
/// A class which is convertible to any expected and that definitly holds no
|
/// A class which is convertible to any result and that definitly holds no
|
||||||
/// value so the real expected gets invalidated when
|
/// value so the real result gets invalidated when
|
||||||
/// this object is passed to it
|
/// this object is passed to it
|
||||||
struct empty_expected {};
|
struct empty_result {};
|
||||||
|
|
||||||
/// A class which is convertible to any expected and that definitly holds
|
/// A class which is convertible to any result and that definitly holds
|
||||||
/// an exception which is then passed to the converted expected object.
|
/// an exception which is then passed to the converted result object.
|
||||||
class exceptional_expected {
|
class exceptional_result {
|
||||||
exception_t exception_;
|
exception_t exception_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
exceptional_expected() = delete;
|
exceptional_result() = delete;
|
||||||
exceptional_expected(exceptional_expected const&) = default;
|
exceptional_result(exceptional_result const&) = default;
|
||||||
exceptional_expected(exceptional_expected&&) = default;
|
exceptional_result(exceptional_result&&) = default;
|
||||||
exceptional_expected& operator=(exceptional_expected const&) = default;
|
exceptional_result& operator=(exceptional_result const&) = default;
|
||||||
exceptional_expected& operator=(exceptional_expected&&) = default;
|
exceptional_result& operator=(exceptional_result&&) = default;
|
||||||
~exceptional_expected() = default;
|
~exceptional_result() = default;
|
||||||
|
|
||||||
explicit exceptional_expected(exception_t exception)
|
explicit exceptional_result(exception_t exception)
|
||||||
// NOLINTNEXTLINE(hicpp-move-const-arg, performance-move-const-arg)
|
// NOLINTNEXTLINE(hicpp-move-const-arg, performance-move-const-arg)
|
||||||
: exception_(std::move(exception)) {
|
: exception_(std::move(exception)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exceptional_expected& operator=(exception_t exception) {
|
exceptional_result& operator=(exception_t exception) {
|
||||||
// NOLINTNEXTLINE(hicpp-move-const-arg, performance-move-const-arg)
|
// NOLINTNEXTLINE(hicpp-move-const-arg, performance-move-const-arg)
|
||||||
exception_ = std::move(exception);
|
exception_ = std::move(exception);
|
||||||
return *this;
|
return *this;
|
||||||
@ -84,12 +84,12 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A class similar to the one in the expected proposal,
|
/// A class similar to the one in the result proposal,
|
||||||
/// however it's capable of carrying an exception_t.
|
/// however it's capable of carrying an exception_t.
|
||||||
// TODO -> async_result
|
// TODO -> async_result
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
class expected {
|
class result {
|
||||||
using trait = detail::expected_trait<T...>;
|
using trait = detail::result_trait<T...>;
|
||||||
using value_t = typename trait::value_t;
|
using value_t = typename trait::value_t;
|
||||||
|
|
||||||
detail::container::flat_variant<value_t, exception_t> variant_;
|
detail::container::flat_variant<value_t, exception_t> variant_;
|
||||||
@ -102,29 +102,29 @@ public:
|
|||||||
std::enable_if_t<((sizeof(A) * 0 + sizeof...(T)) > 0)>* = nullptr,
|
std::enable_if_t<((sizeof(A) * 0 + sizeof...(T)) > 0)>* = nullptr,
|
||||||
std::enable_if_t<
|
std::enable_if_t<
|
||||||
std::is_same<A, detail::traits::identity<>>::value>* = nullptr>
|
std::is_same<A, detail::traits::identity<>>::value>* = nullptr>
|
||||||
explicit expected(A = {}) {
|
explicit result(A = {}) {
|
||||||
}
|
}
|
||||||
explicit expected(expected const&) = default;
|
explicit result(result const&) = default;
|
||||||
explicit expected(expected&&) = default;
|
explicit result(result&&) = default;
|
||||||
expected& operator=(expected const&) = default;
|
result& operator=(result const&) = default;
|
||||||
expected& operator=(expected&&) = default;
|
result& operator=(result&&) = default;
|
||||||
~expected() = default;
|
~result() = default;
|
||||||
|
|
||||||
explicit expected(T... values) : variant_(trait::wrap(std::move(values)...)) {
|
explicit result(T... values) : variant_(trait::wrap(std::move(values)...)) {
|
||||||
}
|
}
|
||||||
explicit expected(exception_t exception) : variant_(std::move(exception)) {
|
explicit result(exception_t exception) : variant_(std::move(exception)) {
|
||||||
}
|
}
|
||||||
explicit expected(empty_expected){};
|
explicit result(empty_result){};
|
||||||
explicit expected(exceptional_expected exceptional_expected)
|
explicit result(exceptional_result exceptional_result)
|
||||||
: variant_(std::move(exceptional_expected.get_exception())) {
|
: variant_(std::move(exceptional_result.get_exception())) {
|
||||||
}
|
}
|
||||||
|
|
||||||
expected& operator=(empty_expected) {
|
result& operator=(empty_result) {
|
||||||
set_empty();
|
set_empty();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
expected& operator=(exceptional_expected exceptional_expected) {
|
result& operator=(exceptional_result exceptional_result) {
|
||||||
set_exception(std::move(exceptional_expected.get_exception()));
|
set_exception(std::move(exceptional_result.get_exception()));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,18 +183,19 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
constexpr auto make_expected(T&&... values) {
|
constexpr auto make_result(T&&... values) {
|
||||||
return expected<detail::traits::unrefcv_t<T>...>(std::forward<T>(values));
|
return result<detail::traits::unrefcv_t<T>...>(std::forward<T>(values)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto make_exceptional_expected(exception_t exception) {
|
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
||||||
|
inline auto make_exceptional_result(exception_t exception) {
|
||||||
// NOLINTNEXTLINE(hicpp-move-const-arg, performance-move-const-arg)
|
// NOLINTNEXTLINE(hicpp-move-const-arg, performance-move-const-arg)
|
||||||
return exceptional_expected(std::move(exception));
|
return exceptional_result(std::move(exception));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto make_empty_expected() {
|
inline auto make_empty_result() {
|
||||||
return empty_expected{};
|
return empty_result{};
|
||||||
}
|
}
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
#endif // CONTINUABLE_EXPECTED_HPP_INCLUDED
|
#endif // CONTINUABLE_RESULT_HPP_INCLUDED
|
||||||
@ -48,10 +48,10 @@ namespace cti {}
|
|||||||
#include <continuable/continuable-base.hpp>
|
#include <continuable/continuable-base.hpp>
|
||||||
#include <continuable/continuable-connections.hpp>
|
#include <continuable/continuable-connections.hpp>
|
||||||
#include <continuable/continuable-coroutine.hpp>
|
#include <continuable/continuable-coroutine.hpp>
|
||||||
#include <continuable/continuable-expected.hpp>
|
|
||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
#include <continuable/continuable-promise-base.hpp>
|
#include <continuable/continuable-promise-base.hpp>
|
||||||
#include <continuable/continuable-promisify.hpp>
|
#include <continuable/continuable-promisify.hpp>
|
||||||
|
#include <continuable/continuable-result.hpp>
|
||||||
#include <continuable/continuable-trait.hpp>
|
#include <continuable/continuable-trait.hpp>
|
||||||
#include <continuable/continuable-transforms.hpp>
|
#include <continuable/continuable-transforms.hpp>
|
||||||
#include <continuable/continuable-traverse-async.hpp>
|
#include <continuable/continuable-traverse-async.hpp>
|
||||||
|
|||||||
@ -34,8 +34,8 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <continuable/continuable-expected.hpp>
|
|
||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
|
#include <continuable/continuable-result.hpp>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/hints.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
#include <continuable/detail/features.hpp>
|
#include <continuable/detail/features.hpp>
|
||||||
|
|||||||
@ -36,8 +36,8 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <experimental/coroutine>
|
#include <experimental/coroutine>
|
||||||
#include <continuable/continuable-expected.hpp>
|
|
||||||
#include <continuable/continuable-primitives.hpp>
|
#include <continuable/continuable-primitives.hpp>
|
||||||
|
#include <continuable/continuable-result.hpp>
|
||||||
#include <continuable/detail/core/hints.hpp>
|
#include <continuable/detail/core/hints.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
#include <continuable/detail/features.hpp>
|
#include <continuable/detail/features.hpp>
|
||||||
@ -55,10 +55,10 @@ namespace awaiting {
|
|||||||
using std::experimental::coroutine_handle;
|
using std::experimental::coroutine_handle;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct expected_from_identity;
|
struct result_from_identity;
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
struct expected_from_identity<traits::identity<T...>> {
|
struct result_from_identity<traits::identity<T...>> {
|
||||||
using expected_t = expected<T...>;
|
using result_t = result<T...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// An object which provides the internal buffer and helper methods
|
/// An object which provides the internal buffer and helper methods
|
||||||
@ -66,13 +66,13 @@ struct expected_from_identity<traits::identity<T...>> {
|
|||||||
template <typename Continuable>
|
template <typename Continuable>
|
||||||
class awaitable {
|
class awaitable {
|
||||||
using hint_t = decltype(hints::hint_of(traits::identify<Continuable>{}));
|
using hint_t = decltype(hints::hint_of(traits::identify<Continuable>{}));
|
||||||
using expected_t = typename expected_from_identity<hint_t>::expected_t;
|
using result_t = typename result_from_identity<hint_t>::result_t;
|
||||||
|
|
||||||
/// The continuable which is invoked upon suspension
|
/// The continuable which is invoked upon suspension
|
||||||
Continuable continuable_;
|
Continuable continuable_;
|
||||||
/// A cache which is used to pass the result of the continuation
|
/// A cache which is used to pass the result of the continuation
|
||||||
/// to the coroutine.
|
/// to the coroutine.
|
||||||
expected_t result_;
|
result_t result_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit constexpr awaitable(Continuable&& continuable)
|
explicit constexpr awaitable(Continuable&& continuable)
|
||||||
|
|||||||
@ -28,8 +28,8 @@
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef CONTINUABLE_DETAIL_EXPECTED_TRAITS_HPP_INCLUDED
|
#ifndef CONTINUABLE_DETAIL_RESULT_TRAIT_HPP_INCLUDED
|
||||||
#define CONTINUABLE_DETAIL_EXPECTED_TRAITS_HPP_INCLUDED
|
#define CONTINUABLE_DETAIL_RESULT_TRAIT_HPP_INCLUDED
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -40,9 +40,9 @@
|
|||||||
namespace cti {
|
namespace cti {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
struct expected_trait;
|
struct result_trait;
|
||||||
template <>
|
template <>
|
||||||
struct expected_trait<> {
|
struct result_trait<> {
|
||||||
struct value_t {};
|
struct value_t {};
|
||||||
|
|
||||||
static constexpr value_t wrap() noexcept {
|
static constexpr value_t wrap() noexcept {
|
||||||
@ -50,7 +50,7 @@ struct expected_trait<> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct expected_trait<T> {
|
struct result_trait<T> {
|
||||||
using value_t = T;
|
using value_t = T;
|
||||||
|
|
||||||
static auto wrap(T arg) {
|
static auto wrap(T arg) {
|
||||||
@ -58,7 +58,7 @@ struct expected_trait<T> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename First, typename Second, typename... Rest>
|
template <typename First, typename Second, typename... Rest>
|
||||||
struct expected_trait<First, Second, Rest...> {
|
struct result_trait<First, Second, Rest...> {
|
||||||
using value_t = std::tuple<First, Second, Rest...>;
|
using value_t = std::tuple<First, Second, Rest...>;
|
||||||
|
|
||||||
static auto wrap(First first, Second second, Rest... rest) {
|
static auto wrap(First first, Second second, Rest... rest) {
|
||||||
@ -69,4 +69,4 @@ struct expected_trait<First, Second, Rest...> {
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
#endif // CONTINUABLE_DETAIL_EXPECTED_TRAITS_HPP_INCLUDED
|
#endif // CONTINUABLE_DETAIL_RESULT_TRAIT_HPP_INCLUDED
|
||||||
@ -18,7 +18,7 @@ target_link_libraries(test-continuable-base
|
|||||||
add_executable(test-continuable-single
|
add_executable(test-continuable-single
|
||||||
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-connection-noinst
|
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-connection-noinst
|
||||||
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-flat-variant.cpp
|
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-flat-variant.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-expected.cpp
|
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-result.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-promisify.cpp
|
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-promisify.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-traverse.cpp
|
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-traverse.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-traverse-async.cpp)
|
${CMAKE_CURRENT_LIST_DIR}/single/test-continuable-traverse-async.cpp)
|
||||||
|
|||||||
@ -23,17 +23,17 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <continuable/continuable-expected.hpp>
|
#include <continuable/continuable-result.hpp>
|
||||||
#include <continuable/detail/core/types.hpp>
|
#include <continuable/detail/core/types.hpp>
|
||||||
#include <test-continuable.hpp>
|
#include <test-continuable.hpp>
|
||||||
|
|
||||||
using cti::exception_t;
|
using cti::exception_t;
|
||||||
using cti::expected;
|
using cti::result;
|
||||||
|
|
||||||
static int const CANARY = 373671;
|
static int const CANARY = 373671;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct expected_all_tests : testing::Test {
|
struct result_all_tests : testing::Test {
|
||||||
template <typename V>
|
template <typename V>
|
||||||
auto supply(V&& value) const {
|
auto supply(V&& value) const {
|
||||||
return std::forward<V>(value);
|
return std::forward<V>(value);
|
||||||
@ -44,7 +44,7 @@ struct expected_all_tests : testing::Test {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct expected_all_tests<expected<std::unique_ptr<T>>> : testing::Test {
|
struct result_all_tests<result<std::unique_ptr<T>>> : testing::Test {
|
||||||
template <typename V>
|
template <typename V>
|
||||||
auto supply(V&& value) const {
|
auto supply(V&& value) const {
|
||||||
return std::make_unique<T>(std::forward<V>(value));
|
return std::make_unique<T>(std::forward<V>(value));
|
||||||
@ -55,21 +55,21 @@ struct expected_all_tests<expected<std::unique_ptr<T>>> : testing::Test {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using copyable_type = expected<int>;
|
using copyable_type = result<int>;
|
||||||
using unique_type = expected<std::unique_ptr<int>>;
|
using unique_type = result<std::unique_ptr<int>>;
|
||||||
|
|
||||||
using expected_test_types = testing::Types<unique_type, copyable_type>;
|
using result_test_types = testing::Types<unique_type, copyable_type>;
|
||||||
|
|
||||||
TYPED_TEST_CASE(expected_all_tests, expected_test_types);
|
TYPED_TEST_CASE(result_all_tests, result_test_types);
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, is_default_constructible) {
|
TYPED_TEST(result_all_tests, is_default_constructible) {
|
||||||
TypeParam e;
|
TypeParam e;
|
||||||
expected<> e1;
|
result<> e1;
|
||||||
expected<int> e2;
|
result<int> e2;
|
||||||
expected<int, int> e3;
|
result<int, int> e3;
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, can_carry_errors) {
|
TYPED_TEST(result_all_tests, can_carry_errors) {
|
||||||
{
|
{
|
||||||
TypeParam e(this->supply(CANARY));
|
TypeParam e(this->supply(CANARY));
|
||||||
|
|
||||||
@ -88,12 +88,12 @@ TYPED_TEST(expected_all_tests, can_carry_errors) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, is_empty_constructible) {
|
TYPED_TEST(result_all_tests, is_empty_constructible) {
|
||||||
TypeParam e;
|
TypeParam e;
|
||||||
(void)e;
|
(void)e;
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, is_move_constructible) {
|
TYPED_TEST(result_all_tests, is_move_constructible) {
|
||||||
{
|
{
|
||||||
TypeParam e(TypeParam(this->supply(CANARY)));
|
TypeParam e(TypeParam(this->supply(CANARY)));
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ TYPED_TEST(expected_all_tests, is_move_constructible) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, is_value_move_assignable) {
|
TYPED_TEST(result_all_tests, is_value_move_assignable) {
|
||||||
TypeParam old(this->supply(CANARY));
|
TypeParam old(this->supply(CANARY));
|
||||||
TypeParam e;
|
TypeParam e;
|
||||||
e = std::move(old);
|
e = std::move(old);
|
||||||
@ -122,7 +122,7 @@ TYPED_TEST(expected_all_tests, is_value_move_assignable) {
|
|||||||
EXPECT_FALSE(e.is_exception());
|
EXPECT_FALSE(e.is_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, is_error_move_assignable) {
|
TYPED_TEST(result_all_tests, is_error_move_assignable) {
|
||||||
TypeParam old(exception_t{});
|
TypeParam old(exception_t{});
|
||||||
TypeParam e;
|
TypeParam e;
|
||||||
e = std::move(old);
|
e = std::move(old);
|
||||||
@ -132,7 +132,7 @@ TYPED_TEST(expected_all_tests, is_error_move_assignable) {
|
|||||||
EXPECT_TRUE(e.is_exception());
|
EXPECT_TRUE(e.is_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(expected_copyable_tests, is_copy_constructible) {
|
TEST(result_copyable_tests, is_copy_constructible) {
|
||||||
{
|
{
|
||||||
copyable_type const e_old(CANARY);
|
copyable_type const e_old(CANARY);
|
||||||
copyable_type e(e_old);
|
copyable_type e(e_old);
|
||||||
@ -153,7 +153,7 @@ TEST(expected_copyable_tests, is_copy_constructible) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(expected_copyable_tests, is_copy_assignable) {
|
TEST(result_copyable_tests, is_copy_assignable) {
|
||||||
{
|
{
|
||||||
copyable_type const e_old(CANARY);
|
copyable_type const e_old(CANARY);
|
||||||
copyable_type e;
|
copyable_type e;
|
||||||
@ -176,8 +176,8 @@ TEST(expected_copyable_tests, is_copy_assignable) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, is_constructible_from_error_helper) {
|
TYPED_TEST(result_all_tests, is_constructible_from_error_helper) {
|
||||||
cti::exceptional_expected e1(exception_t{});
|
cti::exceptional_result e1(exception_t{});
|
||||||
{ auto e2 = e1; }
|
{ auto e2 = e1; }
|
||||||
auto e2 = std::move(e1);
|
auto e2 = std::move(e1);
|
||||||
|
|
||||||
@ -188,8 +188,8 @@ TYPED_TEST(expected_all_tests, is_constructible_from_error_helper) {
|
|||||||
EXPECT_TRUE(e.is_exception());
|
EXPECT_TRUE(e.is_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, is_assignable_from_error_helper) {
|
TYPED_TEST(result_all_tests, is_assignable_from_error_helper) {
|
||||||
cti::exceptional_expected e1(exception_t{});
|
cti::exceptional_result e1(exception_t{});
|
||||||
{ auto e2 = e1; }
|
{ auto e2 = e1; }
|
||||||
auto e2 = std::move(e1);
|
auto e2 = std::move(e1);
|
||||||
|
|
||||||
@ -201,8 +201,8 @@ TYPED_TEST(expected_all_tests, is_assignable_from_error_helper) {
|
|||||||
EXPECT_TRUE(e.is_exception());
|
EXPECT_TRUE(e.is_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, is_constructible_from_empty_helper) {
|
TYPED_TEST(result_all_tests, is_constructible_from_empty_helper) {
|
||||||
cti::empty_expected e1;
|
cti::empty_result e1;
|
||||||
{ auto e2 = e1; }
|
{ auto e2 = e1; }
|
||||||
auto e2 = std::move(e1);
|
auto e2 = std::move(e1);
|
||||||
|
|
||||||
@ -213,8 +213,8 @@ TYPED_TEST(expected_all_tests, is_constructible_from_empty_helper) {
|
|||||||
EXPECT_TRUE(e.is_empty());
|
EXPECT_TRUE(e.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(expected_all_tests, is_assignable_from_empty_helper) {
|
TYPED_TEST(result_all_tests, is_assignable_from_empty_helper) {
|
||||||
cti::empty_expected e1;
|
cti::empty_result e1;
|
||||||
{ auto e2 = e1; }
|
{ auto e2 = e1; }
|
||||||
auto e2 = std::move(e1);
|
auto e2 = std::move(e1);
|
||||||
|
|
||||||
@ -227,16 +227,16 @@ TYPED_TEST(expected_all_tests, is_assignable_from_empty_helper) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This regression test shows a memory leak which happens when using the
|
// This regression test shows a memory leak which happens when using the
|
||||||
// expected class move constructed from another expected object.
|
// result class move constructed from another result object.
|
||||||
TEST(expected_single_test, test_leak_regression) {
|
TEST(result_single_test, test_leak_regression) {
|
||||||
// expected_all_tests<cti::detail::util::expected<std::__1::unique_ptr<int,
|
// result_all_tests<cti::detail::util::result<std::__1::unique_ptr<int,
|
||||||
// std::__1::default_delete<int> > > >::supply<int const&>(int const&)
|
// std::__1::default_delete<int> > > >::supply<int const&>(int const&)
|
||||||
// const
|
// const
|
||||||
// continuable/build/../test/unit-test/test-continuable-expected.cpp:52
|
// continuable/build/../test/unit-test/test-continuable-result.cpp:52
|
||||||
// 3: #3 0x11cf07a in
|
// 3: #3 0x11cf07a in
|
||||||
// expected_all_tests_is_value_assignable_Test<cti::detail::util::expected<std::__1::unique_ptr<int,
|
// result_all_tests_is_value_assignable_Test<cti::detail::util::result<std::__1::unique_ptr<int,
|
||||||
// std::__1::default_delete<int> > > >::TestBody()
|
// std::__1::default_delete<int> > > >::TestBody()
|
||||||
// continuable/build/../test/unit-test/test-continuable-expected.cpp:133:15
|
// continuable/build/../test/unit-test/test-continuable-result.cpp:133:15
|
||||||
// 3: #4 0x1339e4e in void
|
// 3: #4 0x1339e4e in void
|
||||||
// testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,
|
// testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,
|
||||||
// void>(testing::Test*, void (testing::Test::*)(), char const*)
|
// void>(testing::Test*, void (testing::Test::*)(), char const*)
|
||||||
@ -249,7 +249,7 @@ TEST(expected_single_test, test_leak_regression) {
|
|||||||
delete val;
|
delete val;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto e(expected<std::shared_ptr<int>>(std::move(ptr)));
|
auto e(result<std::shared_ptr<int>>(std::move(ptr)));
|
||||||
ASSERT_TRUE(e.is_value());
|
ASSERT_TRUE(e.is_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user