Merge remote-tracking branch 'origin/hotfix/multimap_erase_bug' into development

This commit is contained in:
John Wellbelove 2019-11-05 12:20:44 +00:00
commit ba903e37ba
9 changed files with 89 additions and 4 deletions

View File

@ -593,6 +593,11 @@ namespace etl
// otherwise we might lose the other child of the swap node
replacement = swap->children[1 - swap->dir];
if (replacement != nullptr)
{
replacement->parent = swap->parent;
}
// Point swap node to detached node's parent, children and weight
swap->parent = detached->parent;
swap->children[(uint_least8_t) kLeft] = detached->children[(uint_least8_t) kLeft];

View File

@ -276,6 +276,11 @@ namespace etl
// otherwise we might lose the other child of the swap node
replacement = swap->children[1 - swap->dir];
if (replacement != nullptr)
{
replacement->parent = swap->parent;
}
// Point swap node to detached node's parent, children and weight
swap->parent = detached->parent;
swap->children[kLeft] = detached->children[kLeft];

View File

@ -39,7 +39,7 @@ SOFTWARE.
#define ETL_VERSION_MAJOR 14
#define ETL_VERSION_MINOR 35
#define ETL_VERSION_PATCH 4
#define ETL_VERSION_PATCH 5
#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)

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library",
"version": "14.35.4",
"version": "14.35.5",
"authors": {
"name": "John Wellbelove",
"email": "<john.wellbelove@etlcpp.com>"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=14.35.4
version=14.35.5
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

View File

@ -1,3 +1,7 @@
===============================================================================
14.35.5
Bug fix for etl::multiset & etl::multimap erase.
===============================================================================
14.35.4
Bug fix for etl::set & etl::map lower_bound.

View File

@ -1144,5 +1144,40 @@ namespace
}
}
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_erase_bug)
{
using Data = etl::multimap<int, int, 10>;
int keys[10] = { 3, 2, 1, 0, 3, 0, 3, 0, 2, 2 };
Data data;
for (int eltNum = 0; eltNum != 10; ++eltNum)
{
data.insert(Data::value_type(keys[eltNum], eltNum));
}
data.erase(2);
int prv = INT_MAX;
Data::const_reverse_iterator pos;
bool pass = true;
for (pos = data.crbegin(); pos != data.crend(); ++pos)
{
if (pos->first > prv)
{
pass = false;
break;
}
prv = pos->first;
}
CHECK(pass);
}
};
}

View File

@ -1102,5 +1102,40 @@ namespace
}
}
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_erase_bug)
{
using Data = etl::multiset<int, 10>;
int keys[10] = { 3, 2, 1, 0, 3, 0, 3, 0, 2, 2 };
Data data;
for (int eltNum = 0; eltNum != 10; ++eltNum)
{
data.insert(Data::value_type(keys[eltNum]));
}
data.erase(2);
int prv = INT_MAX;
Data::const_reverse_iterator pos;
bool pass = true;
for (pos = data.crbegin(); pos != data.crend(); ++pos)
{
if (*pos > prv)
{
pass = false;
break;
}
prv = *pos;
}
CHECK(pass);
}
};
}

View File

@ -221,7 +221,7 @@
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
<LanguageStandard>stdcpp14</LanguageStandard>
<LanguageStandard>stdcpp17</LanguageStandard>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
@ -326,6 +326,7 @@
<AdditionalIncludeDirectories>../../../unittest-cpp/UnitTest++/;../../include;../../include/etl/c;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>