[libcalamares] Be far more detailed in comparing maps
- just comparing a==b (both QVariantMap) gives a not-so-informative message, so go through the keys looking for differences.
This commit is contained in:
parent
69cd87909b
commit
c6463a30ea
@ -109,16 +109,49 @@ findConf( const QDir& d )
|
|||||||
return mine;
|
return mine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibCalamaresTests::recursiveCompareMap(const QVariantMap& a, const QVariantMap& b, int depth )
|
||||||
|
{
|
||||||
|
cDebug() << "Comparing depth" << depth << a.count() << b.count();
|
||||||
|
QCOMPARE( a.keys(), b.keys() );
|
||||||
|
for ( const auto& k : a.keys() )
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << k;
|
||||||
|
const auto& av = a[k];
|
||||||
|
const auto& bv = b[k];
|
||||||
|
|
||||||
|
if ( av.typeName() != bv.typeName() )
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "a type" << av.typeName() << av;
|
||||||
|
cDebug() << Logger::SubEntry << "b type" << bv.typeName() << bv;
|
||||||
|
}
|
||||||
|
QCOMPARE( av.typeName(), bv.typeName() );
|
||||||
|
if ( av.canConvert<QVariantMap>() )
|
||||||
|
{
|
||||||
|
recursiveCompareMap( av.toMap(), bv.toMap(), depth+1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QCOMPARE( av, bv );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LibCalamaresTests::testLoadSaveYamlExtended()
|
LibCalamaresTests::testLoadSaveYamlExtended()
|
||||||
{
|
{
|
||||||
|
bool loaded_ok;
|
||||||
for ( const auto& confname : findConf( QDir( "../src" ) ) )
|
for ( const auto& confname : findConf( QDir( "../src" ) ) )
|
||||||
{
|
{
|
||||||
|
loaded_ok = true;
|
||||||
cDebug() << "Testing" << confname;
|
cDebug() << "Testing" << confname;
|
||||||
auto map = CalamaresUtils::loadYaml( confname );
|
auto map = CalamaresUtils::loadYaml( confname, &loaded_ok );
|
||||||
|
QVERIFY( loaded_ok );
|
||||||
QVERIFY( CalamaresUtils::saveYaml( "out.yaml", map ) );
|
QVERIFY( CalamaresUtils::saveYaml( "out.yaml", map ) );
|
||||||
auto othermap = CalamaresUtils::loadYaml( "out.yaml" );
|
auto othermap = CalamaresUtils::loadYaml( "out.yaml", &loaded_ok );
|
||||||
|
QVERIFY( loaded_ok );
|
||||||
|
QCOMPARE( map.keys(), othermap.keys() );
|
||||||
|
recursiveCompareMap( map, othermap, 0 );
|
||||||
QCOMPARE( map, othermap );
|
QCOMPARE( map, othermap );
|
||||||
}
|
}
|
||||||
QFile::remove( "out.yaml" );
|
QFile::remove( "out.yaml" );
|
||||||
|
@ -44,6 +44,9 @@ private Q_SLOTS:
|
|||||||
void testEntropy();
|
void testEntropy();
|
||||||
void testPrintableEntropy();
|
void testPrintableEntropy();
|
||||||
void testOddSizedPrintable();
|
void testOddSizedPrintable();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void recursiveCompareMap( const QVariantMap& a, const QVariantMap& b, int depth );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user