qa: ignore duplicates in PNS regression test reference data

This commit is contained in:
Tomasz Włostowski 2023-05-31 16:40:27 +02:00 committed by Tomasz Wlostowski
parent b1ae093fe6
commit b22b0e5d03
1 changed files with 32 additions and 5 deletions

View File

@ -233,6 +233,30 @@ bool comparePnsItems( const PNS::ITEM*a , const PNS::ITEM* b )
}
const std::set<PNS::ITEM*> deduplicate( const std::set<PNS::ITEM*>& items )
{
std::set<PNS::ITEM*> rv;
for( auto item : items )
{
bool isDuplicate = false;
for (auto ritem : rv )
{
if( comparePnsItems( ritem, item) )
{
isDuplicate = true;
break;
}
if( !isDuplicate )
rv.insert( item );
}
}
return rv;
}
bool PNS_LOG_FILE::COMMIT_STATE::Compare( const PNS_LOG_FILE::COMMIT_STATE& aOther )
{
COMMIT_STATE check( aOther );
@ -252,21 +276,24 @@ bool PNS_LOG_FILE::COMMIT_STATE::Compare( const PNS_LOG_FILE::COMMIT_STATE& aOth
}
}
for( auto item : m_addedItems )
auto addedItems = deduplicate( m_addedItems );
auto chkAddedItems = deduplicate( check.m_addedItems );
for( auto item : addedItems )
{
for( auto chk : check.m_addedItems )
for( auto chk : chkAddedItems )
{
if( comparePnsItems( item, chk ) )
{
check.m_addedItems.erase( chk );
chkAddedItems.erase( chk );
break;
}
}
}
//printf("post-compare: %d/%d\n", check.m_addedItems.size(), check.m_removedIds.size() );
//printf("post-compare: %d/%d\n", chkAddedItems.size(), check.m_removedIds.size() );
return check.m_addedItems.empty() && check.m_removedIds.empty();
return chkAddedItems.empty() && check.m_removedIds.empty();
}