Fix is_truncated in basic_string (#1223)

Co-authored-by: Iványi Béla <bela.ivanyi@idata.hu>
This commit is contained in:
Iványi Béla 2025-11-29 10:38:10 +01:00 committed by GitHub
parent efd5c57419
commit 79b41c85af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -770,7 +770,7 @@ namespace etl
set_truncated(n > CAPACITY);
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
ETL_ASSERT(is_truncated == false, ETL_ERROR(string_truncation));
ETL_ASSERT(is_truncated() == false, ETL_ERROR(string_truncation));
#endif
#endif
@ -918,7 +918,7 @@ namespace etl
set_truncated(n > free_space);
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
ETL_ASSERT(is_truncated == false, ETL_ERROR(string_truncation));
ETL_ASSERT(is_truncated() == false, ETL_ERROR(string_truncation));
#endif
#endif
@ -2774,7 +2774,7 @@ namespace etl
set_truncated((count > free_space) || this->is_truncated() || truncated);
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
ETL_ASSERT(is_truncated == false, ETL_ERROR(string_truncation));
ETL_ASSERT(is_truncated() == false, ETL_ERROR(string_truncation));
#endif
#endif
@ -2820,7 +2820,7 @@ namespace etl
#if ETL_HAS_STRING_TRUNCATION_CHECKS
set_truncated(truncated);
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
ETL_ASSERT(is_truncated == false, ETL_ERROR(string_truncation));
ETL_ASSERT(is_truncated() == false, ETL_ERROR(string_truncation));
#endif
#endif

View File

@ -141,7 +141,6 @@ namespace
TEST_FIXTURE(SetupFixture, test_make_string_with_capacity_truncated)
{
constexpr size_t CAPACITY = 10UL;
size_t length = strlen("Hello World");
#if ETL_HAS_ERROR_ON_STRING_TRUNCATION
CHECK_THROW(auto ctext = etl::make_string_with_capacity<CAPACITY>("Hello World"), etl::string_truncation);
@ -149,6 +148,8 @@ namespace
CHECK_THROW(auto u16text = etl::make_string_with_capacity<CAPACITY>(u"Hello World"), etl::string_truncation);;
CHECK_THROW(auto u32text = etl::make_string_with_capacity<CAPACITY>(U"Hello World"), etl::string_truncation);;
#else
size_t length = strlen("Hello World");
auto ctext = etl::make_string_with_capacity<CAPACITY>("Hello World");
auto wtext = etl::make_string_with_capacity<CAPACITY>(L"Hello World");
auto u16text = etl::make_string_with_capacity<CAPACITY>(u"Hello World");