diff --git a/include/etl/deque.h b/include/etl/deque.h index ed64b7e8..d9272395 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -696,9 +696,6 @@ namespace etl initialise(); - _begin.index = 0; - _end.index = 0; - while (n > 0) { create_element_back(value); @@ -2087,12 +2084,7 @@ namespace etl return; } - if (!empty()) - { - --_begin; - } - - _begin -= n - 1; + _begin -= n; iterator item = _begin; diff --git a/include/etl/version.h b/include/etl/version.h index e240ba3d..720bc3bc 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 18 #define ETL_VERSION_MINOR 0 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_PATCH 1 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index c6331c25..43b576a3 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "18.0.0", + "version": "18.0.1", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 13119685..b50b8b52 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=18.0.0 +version=18.0.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index 5ea596cb..1dd79df8 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +18.0.1 +Fixed 'insert to empty container' bug in etl::deque. + =============================================================================== 18.0.0 ************************* diff --git a/test/test_deque.cpp b/test/test_deque.cpp index 6e720127..f3f13aa4 100644 --- a/test/test_deque.cpp +++ b/test/test_deque.cpp @@ -94,6 +94,10 @@ namespace { DataDC data; + CHECK(data.empty()); + CHECK(!data.full()); + CHECK(data.begin() == data.end()); + CHECK_EQUAL(0U, data.size()); CHECK_EQUAL(SIZE, data.max_size()); } @@ -788,8 +792,6 @@ namespace CHECK(data.empty()); } - - //************************************************************************* TEST(test_insert_to_empty) { @@ -800,6 +802,7 @@ namespace data.insert(data.begin(), valuesToInsert.begin(), valuesToInsert.end()); + CHECK_EQUAL(insertCount, std::distance(data.begin(), data.end())); CHECK(data.size() == insertCount); CHECK(data[0] == value); CHECK(data[1] == value); @@ -815,6 +818,7 @@ namespace Compare_Data::iterator cposition = compare_data.insert(compare_data.begin(), N14); DataNDC::iterator position = data.insert(data.begin(), N14); + CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK_EQUAL(std::distance(compare_data.begin(), cposition), std::distance(data.begin(), position)); @@ -829,6 +833,7 @@ namespace Compare_Data::iterator cposition = compare_data.emplace(compare_data.begin(), N14.value); DataNDC::iterator position = data.emplace(data.begin(), N14.value); + CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK_EQUAL(std::distance(compare_data.begin(), cposition), std::distance(data.begin(), position)); @@ -843,6 +848,7 @@ namespace Compare_Data::iterator cposition = compare_data.insert(compare_data.end(), N14); DataNDC::iterator position = data.insert(data.end(), N14); + CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK_EQUAL(std::distance(compare_data.begin(), cposition), std::distance(data.begin(), position)); @@ -857,6 +863,7 @@ namespace Compare_Data::iterator cposition = compare_data.emplace(compare_data.end(), N14.value); DataNDC::iterator position = data.emplace(data.end(), N14.value); + CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK_EQUAL(std::distance(compare_data.begin(), cposition), std::distance(data.begin(), position)); @@ -871,6 +878,7 @@ namespace Compare_Data::iterator cposition = compare_data.insert(compare_data.begin() + 3, N14); DataNDC::iterator position = data.insert(data.begin() + 3, N14); + CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK_EQUAL(std::distance(compare_data.begin(), cposition), std::distance(data.begin(), position)); @@ -881,6 +889,7 @@ namespace cposition = compare_data.insert(compare_data.begin() + 4, N14); position = data.insert(data.begin() + 4, N14); + CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK_EQUAL(std::distance(compare_data.begin(), cposition), std::distance(data.begin(), position)); @@ -895,6 +904,7 @@ namespace Compare_Data::iterator cposition = compare_data.emplace(compare_data.begin() + 3, N14.value); DataNDC::iterator position = data.emplace(data.begin() + 3, N14.value); + CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK_EQUAL(std::distance(compare_data.begin(), cposition), std::distance(data.begin(), position)); @@ -905,6 +915,7 @@ namespace cposition = compare_data.emplace(compare_data.begin() + 4, N14.value); position = data.emplace(data.begin() + 4, N14.value); + CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); CHECK_EQUAL(std::distance(compare_data.begin(), cposition), std::distance(data.begin(), position)); @@ -961,6 +972,7 @@ namespace compare_data.insert(compare_data.begin() + offset, range.begin(), range.end()); data.insert(data.begin() + offset, range.begin(), range.end()); + CHECK_EQUAL(compare_data.size(), std::distance(data.begin(), data.end())); CHECK_EQUAL(compare_data.size(), data.size()); CHECK(std::equal(compare_data.begin(), compare_data.end(), data.begin())); }