aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-01-10 17:30:20 +0100
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-01-10 19:09:06 +0100
commit6c121793496879a2b063fe0793398aac9b7be4e2 (patch)
treea5d914cbdd8f961325c792776e09fd290067a255
parent789877ceaac15af1b0a6644a8c14422787a898dc (diff)
Fix profile test.
We don't throw exceptions anymore. Change-Id: I4a8baba0b3fd0d6af7adceb4c6ef905f63b84efd Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--src/lib/tools/tst_tools.cpp81
1 files changed, 28 insertions, 53 deletions
diff --git a/src/lib/tools/tst_tools.cpp b/src/lib/tools/tst_tools.cpp
index c1af58f70..34571d7e3 100644
--- a/src/lib/tools/tst_tools.cpp
+++ b/src/lib/tools/tst_tools.cpp
@@ -83,67 +83,42 @@ void TestTools::fileCaseCheck()
void TestTools::testProfiles()
{
- bool exceptionCaught;
Profile parentProfile("parent", m_settings);
Profile childProfile("child", m_settings);
- try {
- parentProfile.removeBaseProfile();
- parentProfile.remove("testKey");
- QCOMPARE(parentProfile.value("testKey", "none").toString(), QLatin1String("none"));
- parentProfile.setValue("testKey", "testValue");
- QCOMPARE(parentProfile.value("testKey").toString(), QLatin1String("testValue"));
+ parentProfile.removeBaseProfile();
+ parentProfile.remove("testKey");
+ QCOMPARE(parentProfile.value("testKey", "none").toString(), QLatin1String("none"));
+ parentProfile.setValue("testKey", "testValue");
+ QCOMPARE(parentProfile.value("testKey").toString(), QLatin1String("testValue"));
- childProfile.remove("testKey");
- childProfile.removeBaseProfile();
- QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("none"));
- childProfile.setBaseProfile("parent");
- QCOMPARE(childProfile.value("testKey").toString(), QLatin1String("testValue"));
+ childProfile.remove("testKey");
+ childProfile.removeBaseProfile();
+ QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("none"));
+ childProfile.setBaseProfile("parent");
+ QCOMPARE(childProfile.value("testKey").toString(), QLatin1String("testValue"));
- // Change base profile and check if the inherited value also changes.
- Profile fooProfile("foo", m_settings);
- fooProfile.setValue("testKey", "gnampf");
- childProfile.setBaseProfile("foo");
- QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("gnampf"));
- exceptionCaught = false;
- } catch (ErrorInfo &) {
- exceptionCaught = true;
- }
- QVERIFY(!exceptionCaught);
+ // Change base profile and check if the inherited value also changes.
+ Profile fooProfile("foo", m_settings);
+ fooProfile.setValue("testKey", "gnampf");
+ childProfile.setBaseProfile("foo");
+ QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("gnampf"));
- try {
- childProfile.setBaseProfile("SmurfAlongWithMe");
- childProfile.value("blubb");
- exceptionCaught = false;
- } catch (ErrorInfo &) {
- exceptionCaught = true;
- }
- QVERIFY(exceptionCaught);
+ ErrorInfo errorInfo;
+ childProfile.setBaseProfile("SmurfAlongWithMe");
+ childProfile.value("blubb", QString(), &errorInfo);
+ QVERIFY(errorInfo.hasError());
- try {
- childProfile.setBaseProfile("parent");
- parentProfile.setBaseProfile("child");
- QVERIFY(!childProfile.value("blubb").isValid());
- exceptionCaught = false;
- } catch (ErrorInfo &) {
- exceptionCaught = true;
- }
- QVERIFY(exceptionCaught);
+ errorInfo.clear();
+ childProfile.setBaseProfile("parent");
+ parentProfile.setBaseProfile("child");
+ QVERIFY(!childProfile.value("blubb", QString(), &errorInfo).isValid());
+ QVERIFY(errorInfo.hasError());
- try {
- QVERIFY(!childProfile.allKeys(Profile::KeySelectionNonRecursive).isEmpty());
- exceptionCaught = false;
- } catch (ErrorInfo &) {
- exceptionCaught = true;
- }
- QVERIFY(!exceptionCaught);
+ QVERIFY(!childProfile.allKeys(Profile::KeySelectionNonRecursive).isEmpty());
- try {
- QVERIFY(!childProfile.allKeys(Profile::KeySelectionRecursive).isEmpty());
- exceptionCaught = false;
- } catch (ErrorInfo &) {
- exceptionCaught = true;
- }
- QVERIFY(exceptionCaught);
+ errorInfo.clear();
+ QVERIFY(childProfile.allKeys(Profile::KeySelectionRecursive, &errorInfo).isEmpty());
+ QVERIFY(errorInfo.hasError());
}
void TestTools::testBuildConfigMerging()