[libcalamares] Minor tests for parts of RAII

main
Adriaan de Groot 5 years ago
parent b1b81f27cc
commit 7b6ff8dd37

@ -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,7 +115,8 @@ 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() );
@ -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 );
}

@ -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…
Cancel
Save