Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1969 Fix documentation and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed May 5, 2023
1 parent 31e8e50 commit 27f5fca
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
14 changes: 7 additions & 7 deletions iceoryx_hoofs/test/moduletests/test_vocabulary_expected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ TEST_F(expected_test, CreateWithErrorAndMoveAssignmentLeadsToMovedSource)
EXPECT_EQ(sutDestination.get_error().m_b, B);
}

TEST_F(expected_test, CreateWithOkFreeFunktionWithVoidValueTypeIsSuccessful)
TEST_F(expected_test, CreateWithOkFreeFunctionWithVoidValueTypeIsSuccessful)
{
::testing::Test::RecordProperty("TEST_ID", "6d582b25-1c7d-4519-837c-55d151b324ff");
expected<void, TestError> sut = ok();
ASSERT_THAT(sut.has_error(), Eq(false));
}

TEST_F(expected_test, CreateWithOkFreeFunktionByCopyIsSuccessful)
TEST_F(expected_test, CreateWithOkFreeFunctionByCopyIsSuccessful)
{
::testing::Test::RecordProperty("TEST_ID", "d3c24c27-432d-4a4b-8d55-6e723bc88c46");
constexpr int VALUE = 111;
Expand All @@ -341,7 +341,7 @@ TEST_F(expected_test, CreateWithOkFreeFunktionByCopyIsSuccessful)
EXPECT_THAT(sut.value(), Eq(VALUE));
}

TEST_F(expected_test, CreateWithOkFreeFunktionByMoveIsSuccessful)
TEST_F(expected_test, CreateWithOkFreeFunctionByMoveIsSuccessful)
{
::testing::Test::RecordProperty("TEST_ID", "b1320e1f-3613-4085-8125-fc95d584681c");
constexpr int A{44};
Expand All @@ -353,7 +353,7 @@ TEST_F(expected_test, CreateWithOkFreeFunktionByMoveIsSuccessful)
EXPECT_THAT(sut.value().m_b, Eq(B));
}

TEST_F(expected_test, CreateWithOkFreeFunktionByForwardingIsSuccessful)
TEST_F(expected_test, CreateWithOkFreeFunctionByForwardingIsSuccessful)
{
::testing::Test::RecordProperty("TEST_ID", "a3d41181-f4ad-4431-9441-7dfaeb8d6f7f");
constexpr int A{44};
Expand All @@ -364,7 +364,7 @@ TEST_F(expected_test, CreateWithOkFreeFunktionByForwardingIsSuccessful)
EXPECT_THAT(sut.value().m_b, Eq(B));
}

TEST_F(expected_test, CreateWithErrFreeFunktionByCopyIsSuccessful)
TEST_F(expected_test, CreateWithErrFreeFunctionByCopyIsSuccessful)
{
::testing::Test::RecordProperty("TEST_ID", "bb641919-e319-4e9c-af67-e1e8d5dab682");
constexpr TestError ERROR = TestError::ERROR1;
Expand All @@ -373,7 +373,7 @@ TEST_F(expected_test, CreateWithErrFreeFunktionByCopyIsSuccessful)
EXPECT_THAT(sut.get_error(), Eq(ERROR));
}

TEST_F(expected_test, CreateWithErrFreeFunktionByMoveIsSuccessful)
TEST_F(expected_test, CreateWithErrFreeFunctionByMoveIsSuccessful)
{
::testing::Test::RecordProperty("TEST_ID", "f99af97a-16b2-41e6-a808-2d58bfe0fc57");
constexpr int A{666};
Expand All @@ -385,7 +385,7 @@ TEST_F(expected_test, CreateWithErrFreeFunktionByMoveIsSuccessful)
EXPECT_THAT(sut.get_error().m_b, Eq(B));
}

TEST_F(expected_test, CreateWithErrFreeFunktionByForwardingIsSuccessful)
TEST_F(expected_test, CreateWithErrFreeFunctionByForwardingIsSuccessful)
{
::testing::Test::RecordProperty("TEST_ID", "08411afa-e1d3-4a28-9680-f89796f86340");
constexpr int A{44};
Expand Down
8 changes: 4 additions & 4 deletions iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ detail::ok<T> ok(Targs&&... args)
}

template <typename T>
detail::err<T> err(const T& value)
detail::err<T> err(const T& error)
{
return detail::err<T>{value};
return detail::err<T>{error};
}

template <typename T, typename>
detail::err<T> err(T&& value)
detail::err<T> err(T&& error)
{
return detail::err<T>{std::forward<T>(value)};
return detail::err<T>{std::forward<T>(error)};
}

template <typename T, typename... Targs>
Expand Down
26 changes: 17 additions & 9 deletions iceoryx_hoofs/vocabulary/include/iox/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ template <typename T>
using error = detail::err<T>;

/// @brief convenience function to create an 'expected' with a 'void' value type
/// @param T helper template parameter for SFINEA
/// @tparam T helper template parameter for SFINEA
/// @code
/// expected<void, uint64_t> callMe() {
/// //...
Expand All @@ -44,7 +44,8 @@ template <typename T = void, typename = enable_if_void_t<T>>
detail::ok<void> ok();

/// @brief convenience function to create an 'expected' with a value type by copy
/// @param T value type for the 'expected'
/// @tparam T value type for the 'expected'
/// @param[in] value is the value for the 'expected'
/// @code
/// expected<bool, uint64_t> callMe() {
/// //...
Expand All @@ -55,7 +56,8 @@ template <typename T, typename = enable_if_non_void_t<T>>
detail::ok<T> ok(const T& value);

/// @brief convenience function to create an 'expected' with a value type by move
/// @param T value type for the 'expected'
/// @tparam T value type for the 'expected'
/// @param[in] value is the value for the 'expected'
/// @code
/// expected<MyClass, uint64_t> callMe() {
/// //...
Expand All @@ -68,7 +70,9 @@ template <typename T, typename = enable_if_non_void_t<T>, typename = enable_if_n
detail::ok<T> ok(T&& value);

/// @brief convenience function to create an 'expected' with a value type by argument forwarding
/// @param T value type for the 'expected'
/// @tparam T value type for the 'expected'
/// @tparam Targs types for the constructor of the value type
/// @param[in] args... arguments which will be perfectly forwarded to the value type constructor
/// @code
/// expected<SomeClass, uint64_t> callMe() {
/// //...
Expand All @@ -79,18 +83,20 @@ template <typename T, typename... Targs, typename = enable_if_non_void_t<T>>
detail::ok<T> ok(Targs&&... args);

/// @brief convenience function to create an 'expected' with an error type by copy
/// @param T error type for the 'expected'
/// @tparam T error type for the 'expected'
/// @param[in] error is the error for the 'expected'
/// @code
/// expected<bool, uint64_t> callMe() {
/// //...
/// return err(37);
/// }
/// @endcode
template <typename T>
detail::err<T> err(const T& value);
detail::err<T> err(const T& error);

/// @brief convenience function to create an 'expected' with an error type by move
/// @param T error type for the 'expected'
/// @tparam T error type for the 'expected'
/// @param[in] error is the error for the 'expected'
/// @code
/// expected<bool, MyError> callMe() {
/// //...
Expand All @@ -100,10 +106,12 @@ detail::err<T> err(const T& value);
/// }
/// @endcode
template <typename T, typename = enable_if_not_lvalue_referece_t<T>>
detail::err<T> err(T&& value);
detail::err<T> err(T&& error);

/// @brief convenience function to create an 'expected' with an error type by argument forwarding
/// @param T error type for the 'expected'
/// @tparam T error type for the 'expected'
/// @tparam Targs types for the constructor of the error type
/// @param[in] args... arguments which will be perfectly forwarded to the error type constructor
/// @code
/// expected<bool, SomeError> callMe() {
/// //...
Expand Down

0 comments on commit 27f5fca

Please sign in to comment.