From 305cbeb1152cdb6e8242e26dc0ba61a53f3e43e8 Mon Sep 17 00:00:00 2001 From: Tigran Khachatryan <39616689+tigran2008@users.noreply.github.com> Date: Sun, 7 Jul 2024 14:23:25 +0400 Subject: [PATCH] Add tests for "etl/utilities.h" forward --- test/test_utility.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/test_utility.cpp b/test/test_utility.cpp index a1f28e950..b527a706e 100644 --- a/test/test_utility.cpp +++ b/test/test_utility.cpp @@ -80,6 +80,25 @@ namespace static TestClass test; } +#if ETL_USING_CPP11 + namespace ForwardTest + { + constexpr int some_lvalue = 0; + enum ValueType { LVALUE, RVALUE }; + + template + ETL_CONSTEXPR14 ValueType get_value_type(T&) { return LVALUE; } + + template + ETL_CONSTEXPR14 ValueType get_value_type(T&&) { return RVALUE; } + + template + ETL_CONSTEXPR14 ValueType test(T&& value) { + return get_value_type(etl::forward(value)); + } + } // namespace ForwardTest +#endif + namespace { SUITE(test_utility) @@ -666,5 +685,14 @@ namespace CHECK_EQUAL(forward_like_call_type::ConstRValue, template_function_fl(etl::move(u4))); CHECK_EQUAL(forward_like_call_type::ConstRValue, template_function_fl(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 }; }