[libcalamares] Minor tests for parts of RAII
This commit is contained in:
parent
b1b81f27cc
commit
7b6ff8dd37
@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2018 Adriaan de Groot <groot@kde.org>
|
* SPDX-FileCopyrightText: 2018 Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -26,6 +26,7 @@
|
|||||||
#include "CalamaresUtilsSystem.h"
|
#include "CalamaresUtilsSystem.h"
|
||||||
#include "Entropy.h"
|
#include "Entropy.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#include "RAII.h"
|
||||||
#include "UMask.h"
|
#include "UMask.h"
|
||||||
#include "Yaml.h"
|
#include "Yaml.h"
|
||||||
|
|
||||||
@ -114,15 +115,16 @@ findConf( const QDir& d )
|
|||||||
return mine;
|
return mine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibCalamaresTests::recursiveCompareMap(const QVariantMap& a, const QVariantMap& b, int depth )
|
void
|
||||||
|
LibCalamaresTests::recursiveCompareMap( const QVariantMap& a, const QVariantMap& b, int depth )
|
||||||
{
|
{
|
||||||
cDebug() << "Comparing depth" << depth << a.count() << b.count();
|
cDebug() << "Comparing depth" << depth << a.count() << b.count();
|
||||||
QCOMPARE( a.keys(), b.keys() );
|
QCOMPARE( a.keys(), b.keys() );
|
||||||
for ( const auto& k : a.keys() )
|
for ( const auto& k : a.keys() )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << k;
|
cDebug() << Logger::SubEntry << k;
|
||||||
const auto& av = a[k];
|
const auto& av = a[ k ];
|
||||||
const auto& bv = b[k];
|
const auto& bv = b[ k ];
|
||||||
|
|
||||||
if ( av.typeName() != bv.typeName() )
|
if ( av.typeName() != bv.typeName() )
|
||||||
{
|
{
|
||||||
@ -130,9 +132,9 @@ void LibCalamaresTests::recursiveCompareMap(const QVariantMap& a, const QVariant
|
|||||||
cDebug() << Logger::SubEntry << "b type" << bv.typeName() << bv;
|
cDebug() << Logger::SubEntry << "b type" << bv.typeName() << bv;
|
||||||
}
|
}
|
||||||
QCOMPARE( av.typeName(), bv.typeName() );
|
QCOMPARE( av.typeName(), bv.typeName() );
|
||||||
if ( av.canConvert<QVariantMap>() )
|
if ( av.canConvert< QVariantMap >() )
|
||||||
{
|
{
|
||||||
recursiveCompareMap( av.toMap(), bv.toMap(), depth+1 );
|
recursiveCompareMap( av.toMap(), bv.toMap(), depth + 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -289,3 +291,25 @@ LibCalamaresTests::testOddSizedPrintable()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LibCalamaresTests::testBoolSetter()
|
||||||
|
{
|
||||||
|
bool b = false;
|
||||||
|
|
||||||
|
QVERIFY( !b );
|
||||||
|
{
|
||||||
|
QVERIFY( !b );
|
||||||
|
cBoolSetter< true > x( b );
|
||||||
|
QVERIFY( b );
|
||||||
|
}
|
||||||
|
QVERIFY( !b );
|
||||||
|
|
||||||
|
QVERIFY( !b );
|
||||||
|
{
|
||||||
|
QVERIFY( !b );
|
||||||
|
cBoolSetter< false > x( b );
|
||||||
|
QVERIFY( !b ); // Still!
|
||||||
|
}
|
||||||
|
QVERIFY( b );
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2018 Adriaan de Groot <groot@kde.org>
|
* SPDX-FileCopyrightText: 2018 Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -50,6 +50,9 @@ private Q_SLOTS:
|
|||||||
void testPrintableEntropy();
|
void testPrintableEntropy();
|
||||||
void testOddSizedPrintable();
|
void testOddSizedPrintable();
|
||||||
|
|
||||||
|
/** @brief Tests the RAII bits. */
|
||||||
|
void testBoolSetter();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recursiveCompareMap( const QVariantMap& a, const QVariantMap& b, int depth );
|
void recursiveCompareMap( const QVariantMap& a, const QVariantMap& b, int depth );
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user