From a5c57521cb0886bb75e78c366476ae0ee394129d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 4 Oct 2022 18:42:14 +0100 Subject: [PATCH] Fix small issues Move tests to test_iterator --- .gitignore | 1 + include/etl/iterator.h | 283 ++++++++++++++++---------------- include/etl/memory.h | 16 +- include/etl/private/addressof.h | 61 +++++++ test/test_iterator.cpp | 58 ++++++- test/test_utility.cpp | 5 + test/test_vector.cpp | 23 --- 7 files changed, 264 insertions(+), 183 deletions(-) create mode 100644 include/etl/private/addressof.h diff --git a/.gitignore b/.gitignore index dd68c752..85920b12 100644 --- a/.gitignore +++ b/.gitignore @@ -360,3 +360,4 @@ test/etl_error_handler/build-exceptions_and_log_errors-GCC-Debug test/etl_error_handler/build-exceptions-GCC-Debug test/etl_error_handler/exceptions_and_log_errors/.vs examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx +test/vs2022/.vs diff --git a/include/etl/iterator.h b/include/etl/iterator.h index 11e62cde..016eec10 100644 --- a/include/etl/iterator.h +++ b/include/etl/iterator.h @@ -34,6 +34,7 @@ SOFTWARE. #include "platform.h" #include "type_traits.h" #include "utility.h" +#include "private/addressof.h" #if ETL_USING_STL || defined(ETL_IN_UNIT_TEST) #include @@ -91,10 +92,8 @@ namespace etl //*************************************************************************** // advance -#if ETL_NOT_USING_STL - template - ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::output_iterator_tag) + ETL_CONSTEXPR14 void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::output_iterator_tag) { while (n--) { @@ -103,7 +102,7 @@ namespace etl } template - ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::forward_iterator_tag) + ETL_CONSTEXPR14 void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::forward_iterator_tag) { while (n--) { @@ -112,7 +111,7 @@ namespace etl } template - ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::bidirectional_iterator_tag) + ETL_CONSTEXPR14 void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::bidirectional_iterator_tag) { if (n > 0) { @@ -131,34 +130,23 @@ namespace etl } template - ETL_CONSTEXPR17 void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::random_access_iterator_tag) + ETL_CONSTEXPR14 void advance_helper(TIterator& itr, TDistance n, ETL_OR_STD::random_access_iterator_tag) { itr += n; } template - ETL_CONSTEXPR17 void advance(TIterator& itr, TDistance n) + ETL_CONSTEXPR14 void advance(TIterator& itr, TDistance n) { typedef typename etl::iterator_traits::iterator_category tag; advance_helper(itr, n, tag()); } -#else - - template - ETL_CONSTEXPR17 void advance(TIterator& itr, TDistance n) - { - std::advance(itr, n); - } - -#endif - //*************************************************************************** // distance -#if ETL_NOT_USING_STL template - ETL_CONSTEXPR17 typename etl::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::input_iterator_tag) + ETL_CONSTEXPR14 typename etl::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::input_iterator_tag) { typename etl::iterator_traits::difference_type d = 0; @@ -172,7 +160,7 @@ namespace etl } template - ETL_CONSTEXPR17 typename etl::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::forward_iterator_tag) + ETL_CONSTEXPR14 typename etl::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::forward_iterator_tag) { typename etl::iterator_traits::difference_type d = 0; @@ -186,7 +174,7 @@ namespace etl } template - ETL_CONSTEXPR17 typename etl::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::bidirectional_iterator_tag) + ETL_CONSTEXPR14 typename etl::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::bidirectional_iterator_tag) { typename etl::iterator_traits::difference_type d = 0; @@ -200,52 +188,36 @@ namespace etl } template - ETL_CONSTEXPR17 typename etl::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::random_access_iterator_tag) + ETL_CONSTEXPR14 typename etl::iterator_traits::difference_type distance_helper(TIterator first, TIterator last, ETL_OR_STD::random_access_iterator_tag) { return last - first; } template - ETL_CONSTEXPR17 typename etl::iterator_traits::difference_type distance(TIterator first, TIterator last) + ETL_CONSTEXPR14 typename etl::iterator_traits::difference_type distance(TIterator first, TIterator last) { typedef typename etl::iterator_traits::iterator_category tag; return distance_helper(first, last, tag()); } -#else - - template - ETL_CONSTEXPR17 typename std::iterator_traits::difference_type distance(TIterator first, TIterator last) - { - return std::distance(first, last); - } - -#endif - //*************************************************************************** // Previous template - ETL_CONSTEXPR17 TIterator prev(TIterator itr, typename etl::iterator_traits::difference_type n = 1) + ETL_CONSTEXPR14 TIterator prev(TIterator itr, typename etl::iterator_traits::difference_type n = 1) { -#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED etl::advance(itr, -n); -#else - std::advance(itr, -n); -#endif + return itr; } //*************************************************************************** // Next template - ETL_CONSTEXPR17 TIterator next(TIterator itr, typename etl::iterator_traits::difference_type n = 1) + ETL_CONSTEXPR14 TIterator next(TIterator itr, typename etl::iterator_traits::difference_type n = 1) { -#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED etl::advance(itr, n); -#else - std::advance(itr, n); -#endif + return itr; } @@ -281,7 +253,7 @@ namespace etl } template - ETL_CONSTEXPR14 reverse_iterator& operator=(const reverse_iterator& other) + ETL_CONSTEXPR14 reverse_iterator& operator =(const reverse_iterator& other) { current = other.base(); @@ -371,49 +343,49 @@ namespace etl TIterator current; }; - template + template ETL_CONSTEXPR14 bool operator ==(const reverse_iterator& lhs, const reverse_iterator& rhs) { return lhs.base() == rhs.base(); } - template + template ETL_CONSTEXPR14 bool operator !=(const reverse_iterator& lhs, const reverse_iterator& rhs) { return !(lhs == rhs); } - template + template ETL_CONSTEXPR14 bool operator <(const reverse_iterator& lhs, const reverse_iterator& rhs) { return rhs.base() < lhs.base(); } - template + template ETL_CONSTEXPR14 bool operator >(const reverse_iterator& lhs, const reverse_iterator& rhs) { return rhs < lhs; } - template + template ETL_CONSTEXPR14 bool operator <=(const reverse_iterator& lhs, const reverse_iterator& rhs) { return !(rhs < lhs); } - template + template ETL_CONSTEXPR14 bool operator >=(const reverse_iterator& lhs, const reverse_iterator& rhs) { return !(lhs < rhs); } - template + template ETL_CONSTEXPR14 typename reverse_iterator::difference_type operator -(const reverse_iterator& lhs, const reverse_iterator& rhs) { return rhs.base() - lhs.base(); } - template + template ETL_CONSTEXPR14 reverse_iterator operator +(TDifference n, const reverse_iterator& itr) { return itr.operator +(n); @@ -610,184 +582,219 @@ namespace etl // back_insert_iterator //*************************************************************************** - /** - * @brief Turns assignment into insertion. - * - * These are output iterators, constructed from a container-of-T. - * Assigning a T to the iterator appends it to the container using push_back. - * - * @tparam TContainer - */ - template - class back_insert_iterator : public iterator + //*************************************************************************** + ///\brief Turns assignment into insertion. + /// + /// These are output iterators, constructed from a container-of-T. + /// Assigning a T to the iterator appends it to the container using push_back. + /// + /// @tparam TContainer + //*************************************************************************** + template + class back_insert_iterator : public etl::iterator { public: + /// A nested typedef for the type of whatever container you used. typedef TContainer container_type; /// The only way to create this %iterator is with a container. - explicit ETL_CONSTEXPR17 back_insert_iterator(TContainer& c) + explicit ETL_CONSTEXPR14 back_insert_iterator(TContainer& c) : container(etl::addressof(c)) { } - /** - * This kind of %iterator doesn't really have a @a position in the - * container (you can think of the position as being permanently at - * the end, if you like). Assigning a value to the %iterator will - * always append the value to the end of the container. - * - * @param value An instance of whatever type container_type::const_reference is; - * presumably a reference-to-const T for container. - * @return This %iterator, for chained operations. - */ - ETL_CONSTEXPR17 back_insert_iterator& operator=(const typename TContainer::value_type& value) + //*************************************************************************** + /// This kind of %iterator doesn't really have a @a position in the + /// container (you can think of the position as being permanently at + /// the end, if you like). Assigning a value to the %iterator will + /// always append the value to the end of the container. + /// + /// @param value An instance of whatever type container_type::const_reference is; + /// presumably a reference-to-const T for container. + /// @return This %iterator, for chained operations. + //*************************************************************************** + ETL_CONSTEXPR14 back_insert_iterator& operator =(const typename TContainer::value_type& value) { container->push_back(value); + return (*this); } #if ETL_USING_CPP11 - ETL_CONSTEXPR17 back_insert_iterator& operator=(typename TContainer::reference value) + //*************************************************************************** + /// Move assignment operator. + //*************************************************************************** + ETL_CONSTEXPR14 back_insert_iterator& operator =(typename TContainer::value_type&& value) { container->push_back(etl::move(value)); + return (*this); } #endif // ETL_USING_CPP11 + //*************************************************************************** + /// Dereference operator. /// Simply returns *this. - ETL_NODISCARD ETL_CONSTEXPR17 back_insert_iterator& operator*() + //*************************************************************************** + ETL_NODISCARD ETL_CONSTEXPR14 back_insert_iterator& operator *() { return (*this); } + //*************************************************************************** + /// Pre-increment operator. /// Simply returns *this. (This %iterator does not @a move.) - ETL_CONSTEXPR17 back_insert_iterator& operator++() + //*************************************************************************** + ETL_CONSTEXPR14 back_insert_iterator& operator ++() { return (*this); } + //*************************************************************************** + /// Post-increment operator. /// Simply returns *this. (This %iterator does not @a move.) - ETL_CONSTEXPR17 back_insert_iterator operator++(int) + //*************************************************************************** + ETL_CONSTEXPR14 back_insert_iterator operator ++(int) { return (*this); } protected: + TContainer* container; }; - /** - * This wrapper function helps in creating back_insert_iterator instances. - * Typing the name of the %iterator requires knowing the precise full - * type of the container, which can be tedious and impedes generic - * programming. Using this function lets you take advantage of automatic - * template parameter deduction, making the compiler match the correct types for you. - * - * @tparam TContainer The container type. - * @param container A container of arbitrary type. - * @return An instance of back_insert_iterator working on @p container. - */ - template - ETL_NODISCARD ETL_CONSTEXPR17 inline ETL_OR_STD::back_insert_iterator back_inserter(TContainer& container) + //*************************************************************************** + /// This wrapper function helps in creating back_insert_iterator instances. + /// Typing the name of the %iterator requires knowing the precise full + /// type of the container, which can be tedious and impedes generic + /// programming. Using this function lets you take advantage of automatic + /// template parameter deduction, making the compiler match the correct types for you. + /// + /// @tparam TContainer The container type. + /// @param container A container of arbitrary type. + /// @return An instance of back_insert_iterator working on @p container. + //*************************************************************************** + template + ETL_NODISCARD + ETL_CONSTEXPR14 + etl::back_insert_iterator back_inserter(TContainer& container) { - return ETL_OR_STD::back_insert_iterator(container); + return etl::back_insert_iterator(container); } //*************************************************************************** // front_insert_iterator //*************************************************************************** - /** - * @brief Turns assignment into insertion. - * - * These are output iterators, constructed from a container-of-T. - * Assigning a T to the iterator prepends it to the container using - * push_front. - * - * Tip: Using the front_inserter function to create these iterators can - * save typing. - * - * @tparam TContainer The container type. - */ + //*************************************************************************** + ///\brief Turns assignment into insertion. + /// + /// These are output iterators, constructed from a container-of-T. + /// Assigning a T to the iterator prepends it to the container using + /// push_front. + /// + /// Tip: Using the front_inserter function to create these iterators can + /// save typing. + /// + ///\tparam TContainer The container type. + //*************************************************************************** template - class front_insert_iterator - : public iterator + class front_insert_iterator : public etl::iterator { public: + /// A nested typedef for the type of whatever container you used. typedef TContainer container_type; + //*************************************************************************** + /// Constructor /// The only way to create this %iterator is with a container. - explicit ETL_CONSTEXPR17 front_insert_iterator(TContainer& c) + //*************************************************************************** + explicit ETL_CONSTEXPR14 front_insert_iterator(TContainer& c) : container(etl::addressof(c)) { } - /** - * This kind of %iterator doesn't really have a @a position in the - * container (you can think of the position as being permanently at - * the front, if you like). Assigning a value to the %iterator will - * always prepend the value to the front of the container. - * - * @param value An instance of whatever type - * container_type::const_reference is; presumably a - * reference-to-const T for container. - * @return This %iterator, for chained operations. - * - */ - ETL_CONSTEXPR17 front_insert_iterator& operator=(const typename TContainer::value_type& value) + //*************************************************************************** + /// This kind of %iterator doesn't really have a @a position in the + /// container (you can think of the position as being permanently at + /// the front, if you like). Assigning a value to the %iterator will + /// always prepend the value to the front of the container. + /// + /// @param value An instance of whatever type + /// container_type::const_reference is; presumably a + /// reference-to-const T for container. + /// @return This %iterator, for chained operations. + //*************************************************************************** + ETL_CONSTEXPR14 front_insert_iterator& operator =(const typename TContainer::value_type& value) { container->push_front(value); return (*this); } #if ETL_USING_CPP11 - ETL_CONSTEXPR17 front_insert_iterator& operator=(typename TContainer::reference value) + //*************************************************************************** + /// Move assignment operator. + //*************************************************************************** + ETL_CONSTEXPR14 front_insert_iterator& operator =(typename TContainer::value_type&& value) { container->push_front(etl::move(value)); return (*this); } #endif // ETL_USING_CPP11 + //*************************************************************************** + /// Dereference operator. /// Simply returns *this. - ETL_NODISCARD ETL_CONSTEXPR17 front_insert_iterator& operator*() + //*************************************************************************** + ETL_NODISCARD ETL_CONSTEXPR14 front_insert_iterator& operator *() { return (*this); } + //*************************************************************************** + /// Pre-increment operator. /// Simply returns *this. (This %iterator does not @a move.) - ETL_CONSTEXPR17 front_insert_iterator& operator++() + //*************************************************************************** + ETL_CONSTEXPR14 front_insert_iterator& operator ++() { return (*this); } + //*************************************************************************** + /// Post-increment operator. /// Simply returns *this. (This %iterator does not @a move.) - ETL_CONSTEXPR17 front_insert_iterator operator++(int) + //*************************************************************************** + ETL_CONSTEXPR14 front_insert_iterator operator ++(int) { return (*this); } protected: + TContainer* container; }; - /** - * This wrapper function helps in creating front_insert_iterator instances. - * Typing the name of the %iterator requires knowing the precise full - * type of the container, which can be tedious and impedes generic - * programming. Using this function lets you take advantage of automatic - * template parameter deduction, making the compiler match the correct - * types for you. - * - * @tparam TContainer The container type. - * @param container A container of arbitrary type. - * @return An instance of front_insert_iterator working on @p x. - */ + //*************************************************************************** + /// This wrapper function helps in creating front_insert_iterator instances. + /// Typing the name of the %iterator requires knowing the precise full + /// type of the container, which can be tedious and impedes generic + /// programming. Using this function lets you take advantage of automatic + /// template parameter deduction, making the compiler match the correct + /// types for you. + /// + ///\tparam TContainer The container type. + ///\param container A container of arbitrary type. + ///\return An instance of front_insert_iterator working on @p x. + //*************************************************************************** template - ETL_NODISCARD ETL_CONSTEXPR17 inline ETL_OR_STD::front_insert_iterator front_inserter(TContainer& container) + ETL_NODISCARD + ETL_CONSTEXPR14 + etl::front_insert_iterator front_inserter(TContainer& container) { - return ETL_OR_STD::front_insert_iterator(container); + return etl::front_insert_iterator(container); } //*************************************************************************** diff --git a/include/etl/memory.h b/include/etl/memory.h index 2c5693dd..ec6db9a4 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -39,6 +39,7 @@ SOFTWARE. #include "nullptr.h" #include "alignment.h" #include "placement_new.h" +#include "private/addressof.h" #include #include @@ -52,21 +53,6 @@ SOFTWARE. namespace etl { - //***************************************************************************** - /// Gets the address of an object. - /// https://en.cppreference.com/w/cpp/memory/addressof - ///\ingroup memory - //***************************************************************************** - template - ETL_CONSTEXPR17 T* addressof(T& t) - { -#if ETL_USING_STL && ETL_USING_CPP11 - return std::addressof(t); -#else - return reinterpret_cast(&const_cast(reinterpret_cast(t))); -#endif - } - #if ETL_NOT_USING_STL //***************************************************************************** /// Fills uninitialised memory range with a value. diff --git a/include/etl/private/addressof.h b/include/etl/private/addressof.h new file mode 100644 index 00000000..67fc8d2f --- /dev/null +++ b/include/etl/private/addressof.h @@ -0,0 +1,61 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2022 John Wellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_ADDRESSOF_INCLUDED +#define ETL_ADDRESSOF_INCLUDED + +#include "../platform.h" + +#if defined(ETL_IN_UNIT_TEST) || ETL_USING_STL + #include +#endif + +///\defgroup memory memory +///\ingroup etl + +namespace etl +{ + //***************************************************************************** + /// Gets the address of an object. + /// https://en.cppreference.com/w/cpp/memory/addressof + ///\ingroup memory + //***************************************************************************** + template + ETL_CONSTEXPR17 T* addressof(T& t) + { +#if ETL_USING_STL && ETL_USING_CPP11 + return std::addressof(t); +#else + return reinterpret_cast(&const_cast(reinterpret_cast(t))); +#endif + } +} + +#endif diff --git a/test/test_iterator.cpp b/test/test_iterator.cpp index 05832567..729c0a50 100644 --- a/test/test_iterator.cpp +++ b/test/test_iterator.cpp @@ -29,6 +29,8 @@ SOFTWARE. #include "unit_test_framework.h" #include +#include +#include #include "etl/iterator.h" @@ -276,7 +278,7 @@ namespace CHECK_EQUAL(*sri, *eri); } - + //************************************************************************* TEST(test_input) { CHECK(!!etl::is_input_iterator::value); @@ -292,6 +294,7 @@ namespace CHECK(!etl::is_random_iterator_concept::value); } + //************************************************************************* TEST(test_output) { CHECK(!etl::is_input_iterator::value); @@ -307,6 +310,7 @@ namespace CHECK(!etl::is_random_iterator_concept::value); } + //************************************************************************* TEST(test_forward) { CHECK(!etl::is_input_iterator::value); @@ -322,6 +326,7 @@ namespace CHECK(!etl::is_random_iterator_concept::value); } + //************************************************************************* TEST(test_bidirectional) { CHECK(!etl::is_input_iterator::value); @@ -337,6 +342,7 @@ namespace CHECK(!etl::is_random_iterator_concept::value); } + //************************************************************************* TEST(test_random) { CHECK(!etl::is_input_iterator::value); @@ -352,6 +358,7 @@ namespace CHECK(!!etl::is_random_iterator_concept::value); } + //************************************************************************* TEST(test_pointer) { CHECK(!etl::is_input_iterator::value); @@ -367,6 +374,7 @@ namespace CHECK(!!etl::is_random_iterator_concept::value); } + //************************************************************************* TEST(test_const_pointer) { CHECK(!etl::is_input_iterator::value); @@ -383,7 +391,7 @@ namespace } //************************************************************************* - TEST(move_iterator_constructors) + TEST(test_move_iterator_constructors) { Item list[] = { Item("1"), Item("2"), Item("3") }; @@ -402,7 +410,7 @@ namespace } //************************************************************************* - TEST(move_iterator_relational_operators) + TEST(test_move_iterator_relational_operators) { Item list[] = { Item("1"), Item("2"), Item("3") }; @@ -434,7 +442,7 @@ namespace } //************************************************************************* - TEST(move_iterator_access_operators) + TEST(test_move_iterator_access_operators) { Item item1("1"); @@ -455,7 +463,7 @@ namespace } //************************************************************************* - TEST(move_iterator_index) + TEST(test_move_iterator_index) { Item list[] = { Item("1"), Item("2"), Item("3") }; @@ -466,7 +474,7 @@ namespace } //************************************************************************* - TEST(move_iterator_increment_decrement) + TEST(test_move_iterator_increment_decrement) { Item list[] = { Item("1"), Item("2"), Item("3") }; @@ -506,7 +514,7 @@ namespace } //************************************************************************* - TEST(move_iterator_subtraction) + TEST(test_move_iterator_subtraction) { Item list[] = { Item("1"), Item("2"), Item("3") }; @@ -517,5 +525,41 @@ namespace CHECK_EQUAL(1, d); } + + //************************************************************************* + TEST(test_front_insert_iterator) + { + std::list input = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + std::list expected = { 81, 64, 49, 36, 25, 16, 9, 4, 1, 0 }; + std::list output; + + auto squared = [](int value) + { + return value * value; + }; + + std::transform(input.cbegin(), input.cend(), etl::front_inserter(output), squared); + + CHECK_EQUAL(expected.size(), output.size()); + CHECK(std::equal(output.begin(), output.end(), expected.begin())); + } + + //************************************************************************* + TEST(test_back_insert_iterator) + { + std::list input = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + std::list expected = { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 }; + std::list output; + + auto squared = [](int value) + { + return value * value; + }; + + std::transform(input.cbegin(), input.cend(), etl::back_inserter(output), squared); + + CHECK_EQUAL(expected.size(), output.size()); + CHECK(std::equal(output.begin(), output.end(), expected.begin())); + } }; } diff --git a/test/test_utility.cpp b/test/test_utility.cpp index aa4c66c9..57350a2f 100644 --- a/test/test_utility.cpp +++ b/test/test_utility.cpp @@ -357,8 +357,10 @@ namespace auto selector = etl::select1st(); +#include "etl/private/diagnostic_pessimizing-move_push.h" CHECK_EQUAL(1, selector(std::move(EtlPair(1, "Hello")))); CHECK_EQUAL(2, selector(std::move(StdPair(2, "Hello")))); +#include "etl/private/diagnostic_pop.h" } //************************************************************************* @@ -407,8 +409,11 @@ namespace StdPair sp2(2, "World"); auto selector = etl::select2nd(); + +#include "etl/private/diagnostic_pessimizing-move_push.h" CHECK_EQUAL(std::string("Hello"), selector(std::move(EtlPair(1, "Hello")))); CHECK_EQUAL(std::string("World"), selector(std::move(StdPair(1, "World")))); +#include "etl/private/diagnostic_pop.h" } //************************************************************************* diff --git a/test/test_vector.cpp b/test/test_vector.cpp index 16a9cc76..70313f3f 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -634,29 +634,6 @@ namespace CHECK(is_equal); } - - - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_back_insert_iterator) - { - Data data={0,1,2,3,4,5,6,7,8,9}; - Data expected={0,1,4,9,16,25,36,49,64,81}; - Data transformed; - - auto squared = [](int value){ - return value*value; - }; - - etl::transform(data.cbegin(),data.cend(),etl::back_inserter(transformed),squared); - - CHECK_EQUAL(expected.size(), transformed.size()); - - bool transformed_equals_expected = std::equal(transformed.begin(), - transformed.end(), - expected.begin()); - CHECK(transformed_equals_expected); - } - //************************************************************************* TEST_FIXTURE(SetupFixture, test_emplace_back) {