Skip to content

Commit

Permalink
Add tests for "etl/utilities.h" forward<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
tigran2008 authored Jul 7, 2024
1 parent dd437f9 commit 305cbeb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/test_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,25 @@ namespace
static TestClass test;
}

#if ETL_USING_CPP11
namespace ForwardTest
{
constexpr int some_lvalue = 0;
enum ValueType { LVALUE, RVALUE };

template <class T>
ETL_CONSTEXPR14 ValueType get_value_type(T&) { return LVALUE; }

template <class T>
ETL_CONSTEXPR14 ValueType get_value_type(T&&) { return RVALUE; }

template <typename T>
ETL_CONSTEXPR14 ValueType test(T&& value) {
return get_value_type(etl::forward<T>(value));
}
} // namespace ForwardTest
#endif

namespace
{
SUITE(test_utility)
Expand Down Expand Up @@ -666,5 +685,14 @@ namespace
CHECK_EQUAL(forward_like_call_type::ConstRValue, template_function_fl<TFL&&>(etl::move(u4)));
CHECK_EQUAL(forward_like_call_type::ConstRValue, template_function_fl<const TFL&&>(etl::move(u4)));
}

#if ETL_USING_CPP11
//*********************************
TEST(test_forward)
{
CHECK_EQUAL(ForwardTest::test(0), ForwardTest::RVALUE);
CHECK_EQUAL(ForwardTest::test(ForwardTest::some_lvalue), ForwardTest::LVALUE);
}
#endif
};
}

0 comments on commit 305cbeb

Please sign in to comment.