From a86b1240196462cfb7bbe97b551c43ae5aff5d4a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 16 Mar 2025 19:07:25 +0000 Subject: [PATCH] Attempt to fix some sanitizer issues for tests --- include/etl/intrusive_forward_list.h | 5 ++++- test/test_map.cpp | 7 ++++--- test/test_multi_span.cpp | 14 ++------------ 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 6cb44280..7e6d4dba 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -322,7 +322,10 @@ namespace etl if (p_next != &this->terminator) { link_type* p_unlinked = etl::unlink_after(link); - p_unlinked->clear(); + if (p_unlinked != ETL_NULLPTR) + { + p_unlinked->clear(); + } --current_size; } } diff --git a/test/test_map.cpp b/test/test_map.cpp index bd8817ce..2c19e4e4 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -37,6 +37,7 @@ SOFTWARE. #include #include "etl/map.h" +#include "etl/string.h" #include "data.h" @@ -1575,7 +1576,7 @@ namespace #if ETL_USING_CPP17 && ETL_HAS_INITIALIZER_LIST && !defined(ETL_TEMPLATE_DEDUCTION_GUIDE_TESTS_DISABLED) TEST_FIXTURE(SetupFixture, test_map_template_deduction) { - using Pair = std::pair; + using Pair = std::pair, int>; etl::map data { Pair{"0", 0}, Pair{"1", 1}, Pair{"2", 2}, Pair{"3", 3}, Pair{"4", 4}, Pair{"5", 5} }; @@ -1596,9 +1597,9 @@ namespace #if ETL_HAS_INITIALIZER_LIST TEST_FIXTURE(SetupFixture, test_make_map) { - using Pair = ETL_OR_STD::pair; + using Pair = ETL_OR_STD::pair, int>; - auto data = etl::make_map>(Pair{ "0", 0 }, Pair{ "1", 1 }, Pair{ "2", 2 }, Pair{ "3", 3 }, Pair{ "4", 4 }, Pair{ "5", 5 }); + auto data = etl::make_map, int, std::less>>(Pair{ "0", 0 }, Pair{ "1", 1 }, Pair{ "2", 2 }, Pair{ "3", 3 }, Pair{ "4", 4 }, Pair{ "5", 5 }); auto v = *data.begin(); using Type = decltype(v); diff --git a/test/test_multi_span.cpp b/test/test_multi_span.cpp index 11c77196..c3e20a6e 100644 --- a/test/test_multi_span.cpp +++ b/test/test_multi_span.cpp @@ -341,14 +341,7 @@ namespace etl::multi_span::iterator ms_itr = ms_int.begin(); etl::multi_span::iterator ms_end_itr = ms_int.end(); - while (ms_itr != ms_end_itr) - { - // Fill the multi span - *ms_itr++ = *exp_itr++; - } - - ms_itr = ms_int.begin(); - exp_itr = expected.begin(); + std::copy(ms_itr, ms_end_itr, exp_itr); while (ms_itr != ms_end_itr) { @@ -554,10 +547,7 @@ namespace multi_span_type::reverse_iterator ms_itr = ms_int.rbegin(); multi_span_type::reverse_iterator ms_end_itr = ms_int.rend(); - while (ms_itr != ms_end_itr) - { - *ms_itr++ = *exp_itr++; - } + std::copy(ms_itr, ms_end_itr, exp_itr); while (ms_itr != ms_end_itr) {