Merge 1d5b4c444dee20851a845b77c04a70c397beb8db into 60ba92928e8af3441f2a4eea5f18fd2563d98ad0

This commit is contained in:
AlvyneZ 2026-10-24 22:25:12 +02:00 committed by GitHub
commit 7aa271e28b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 137 additions and 8 deletions

View File

@ -724,7 +724,7 @@ namespace etl
///\param last The iterator to the last element + 1.
//*********************************************************************
template <typename TIterator>
void assign(TIterator first, TIterator last)
typename etl::enable_if<!etl::is_integral<TIterator>::value, void>::type assign(TIterator first, TIterator last)
{
ETL_STATIC_ASSERT((etl::is_same<typename etl::remove_cv<T>::type,
typename etl::remove_cv< typename etl::iterator_traits< TIterator>::value_type>::type>::value),
@ -1071,7 +1071,7 @@ namespace etl
///\param last The last + 1 element to add.
//*********************************************************************
template <class TIterator>
iterator insert(const_iterator position, TIterator first, TIterator last)
typename etl::enable_if<!etl::is_integral<TIterator>::value, iterator>::type insert(const_iterator position, TIterator first, TIterator last)
{
size_t count = size_t(etl::distance(first, last));
@ -1462,7 +1462,7 @@ namespace etl
///\param last The iterator to the last element + 1.
//*************************************************************************
template <typename TIterator>
indirect_vector(TIterator first, TIterator last)
indirect_vector(TIterator first, TIterator last, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
: etl::iindirect_vector<T>(lookup_vector, storage_pool)
{
this->assign(first, last);
@ -1613,7 +1613,8 @@ namespace etl
///\param last The iterator to the last element + 1.
//*************************************************************************
template <typename TIterator>
indirect_vector_ext(TIterator first, TIterator last, etl::ivector<T*>& lookup_, etl::ipool& pool_)
indirect_vector_ext(TIterator first, TIterator last, etl::ivector<T*>& lookup_, etl::ipool& pool_,
typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0)
: etl::iindirect_vector<T>(lookup_, pool_)
{
ETL_ASSERT(lookup_.capacity() <= pool_.capacity(), ETL_ERROR(indirect_vector_buffer_missmatch));

View File

@ -1201,6 +1201,42 @@ namespace
CHECK_THROW(data.insert(data.begin() + static_cast<ptrdiff_t>(offset), INSERT_SIZE, INITIAL_VALUE), etl::vector_full);
}
//*************************************************************************
TEST(test_constructor_two_parameter_same_type_not_iterator)
{
std::vector<int> compare_data(5, 7);
etl::indirect_vector<int, 10> data(5, 7);
CHECK_EQUAL(compare_data.size(), data.size());
CHECK(std::equal(data.begin(), data.end(), compare_data.begin()));
}
//*************************************************************************
TEST(test_assign_two_parameter_same_type_not_iterator)
{
std::vector<size_t> compare_data;
etl::indirect_vector<size_t, 10> data;
compare_data.assign(5, 7);
data.assign(5, 7);
CHECK_EQUAL(compare_data.size(), data.size());
CHECK(std::equal(data.begin(), data.end(), compare_data.begin()));
}
//*************************************************************************
TEST(test_insert_three_parameter_same_type_not_iterator)
{
std::vector<int> compare_data(3UL, 1);
etl::indirect_vector<int, 10> data(3UL, 1);
compare_data.insert(compare_data.begin(), 2, 7);
data.insert(data.begin(), 2, 7);
CHECK_EQUAL(compare_data.size(), data.size());
CHECK(std::equal(data.begin(), data.end(), compare_data.begin()));
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_insert_position_range)
{

View File

@ -335,6 +335,22 @@ namespace
CHECK_EQUAL(4U, *data2[3]);
}
//*************************************************************************
TEST(test_constructor_two_parameter_same_type_not_iterator)
{
LookupInt lookup;
PoolInt pool;
etl::indirect_vector_ext<int> data(5, 7, lookup, pool);
CHECK_EQUAL(5U, data.size());
CHECK_EQUAL(7, data[0]);
CHECK_EQUAL(7, data[1]);
CHECK_EQUAL(7, data[2]);
CHECK_EQUAL(7, data[3]);
CHECK_EQUAL(7, data[4]);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_assignment)
{

View File

@ -3,6 +3,16 @@ if(CONFIG_ETL)
zephyr_link_libraries(etl::etl)
zephyr_compile_definitions_ifdef(CONFIG_ETL_DEBUG ETL_DEBUG)
zephyr_compile_definitions_ifdef(CONFIG_ETL_CHECK_PUSH_POP ETL_CHECK_PUSH_POP)
zephyr_compile_definitions_ifdef(CONFIG_ETL_LOG_ERRORS ETL_LOG_ERRORS)
zephyr_compile_definitions_ifdef(CONFIG_ETL_USE_ASSERT_FUNCTION ETL_USE_ASSERT_FUNCTION)
zephyr_compile_definitions_ifdef(CONFIG_ETL_THROW_EXCEPTIONS ETL_THROW_EXCEPTIONS)
zephyr_compile_definitions_ifdef(CONFIG_ETL_NO_CHECKS ETL_NO_CHECKS)
zephyr_compile_definitions_ifdef(CONFIG_ETL_VERBOSE_ERRORS ETL_VERBOSE_ERRORS)
zephyr_compile_definitions_ifdef(CONFIG_ETL_MINIMAL_ERRORS ETL_MINIMAL_ERRORS)
zephyr_compile_definitions_ifdef(CONFIG_ETL_CHECK_PUSH_POP ETL_CHECK_PUSH_POP)
zephyr_compile_definitions_ifdef(CONFIG_ETL_CHECK_INDEX_OPERATOR ETL_CHECK_INDEX_OPERATOR)
zephyr_compile_definitions_ifdef(CONFIG_ETL_CHECK_EXTRA ETL_CHECK_EXTRA)
endif()

View File

@ -8,12 +8,78 @@ if ETL
config ETL_DEBUG
bool "Build ETL with debugging checks"
default y if DEBUG
default y if ASSERT
choice ETL_ERROR_MODE
prompt "ETL error handling mode"
help
What ETL does when one of its checks fails.
config ETL_ASSERT_ERRORS
bool "Assert in ETL_DEBUG builds, otherwise ignore"
help
With ETL_DEBUG, a failed check calls assert(). Without it, nothing
is reported, but checks that guard an operation still skip it.
With ETL_LOG_ERRORS, a failed check calls the error handler instead,
with or without ETL_DEBUG.
config ETL_USE_ASSERT_FUNCTION
bool "Call a user assert function"
help
A failed check calls the function registered with
etl::set_assert_function(), and checks that guard an operation
still skip it. Until one is registered, it calls assert(false).
config ETL_THROW_EXCEPTIONS
bool "Throw an exception"
depends on CPP_EXCEPTIONS
help
A failed check throws an etl::exception.
config ETL_NO_CHECKS
bool "No checks"
help
Check conditions are not evaluated.
endchoice # ETL_ERROR_MODE
config ETL_LOG_ERRORS
bool "Call the ETL error handler"
depends on !ETL_USE_ASSERT_FUNCTION && !ETL_NO_CHECKS
help
A failed check calls the callback registered with
etl::error_handler::set_callback(). With ETL_THROW_EXCEPTIONS it
then throws; otherwise, checks that guard an operation still skip
it. With no callback registered, errors are discarded.
choice ETL_ERROR_DETAIL
prompt "ETL error detail level"
help
What information the etl::exception for a failed check carries,
whether it is thrown or passed to the error handler or assert
function. Unused when a failed check calls plain assert().
config ETL_TERSE_ERRORS
bool "Short error code only"
config ETL_VERBOSE_ERRORS
bool "Message, file and line"
config ETL_MINIMAL_ERRORS
bool "Nothing"
endchoice # ETL_ERROR_DETAIL
config ETL_CHECK_PUSH_POP
bool "Enable push/pop checks in ETL"
depends on !ETL_NO_CHECKS
config ETL_LOG_ERRORS
bool "Call ETL error handler instead of assert"
config ETL_CHECK_INDEX_OPERATOR
bool "Enable bounds checks on ETL operator[]"
depends on !ETL_NO_CHECKS
config ETL_CHECK_EXTRA
bool "Enable extra bounds and empty checks in ETL containers"
depends on !ETL_NO_CHECKS
endif # ETL