aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_config.cpp')
-rw-r--r--tests/test_config.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_config.cpp b/tests/test_config.cpp
index a09738b..4d92891 100644
--- a/tests/test_config.cpp
+++ b/tests/test_config.cpp
@@ -45,6 +45,9 @@ private slots:
void markReadDelayIsActuallyRead();
void markReadDelayAcceptsZeroAndNegative();
void markReadDelayRejectsGarbage();
+ void syncOnExitDefaultsToAsk();
+ void syncOnExitReadsAllThreeValues();
+ void syncOnExitWarnsOnGarbage();
void extraMimetypesAppendToBuiltins();
void extraMimetypeDescriptionMayContainComma();
void malformedExtraMimetypeIsSkipped();
@@ -429,6 +432,50 @@ void TestConfig::markReadDelayRejectsGarbage()
QVERIFY(!config.problems().isEmpty());
}
+void TestConfig::syncOnExitDefaultsToAsk()
+{
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral("[general]\n")));
+ QCOMPARE(config.syncOnExit(), Config::SyncOnExit::Ask);
+ QVERIFY(config.problems().isEmpty());
+}
+
+void TestConfig::syncOnExitReadsAllThreeValues()
+{
+ // A bool could only carry two of these. Each is a distinct behaviour at
+ // exit, so each has to round-trip.
+ const QList<QPair<QString, Config::SyncOnExit>> cases = {
+ { QStringLiteral("ask"), Config::SyncOnExit::Ask },
+ { QStringLiteral("always"), Config::SyncOnExit::Always },
+ { QStringLiteral("never"), Config::SyncOnExit::Never },
+ // Case and surrounding space are the user's, not the parser's problem.
+ { QStringLiteral(" Always "), Config::SyncOnExit::Always },
+ };
+
+ for (const auto &testCase : cases) {
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral("[general]\nsync_on_exit=%1\n")
+ .arg(testCase.first)));
+ QCOMPARE(config.syncOnExit(), testCase.second);
+ QVERIFY2(config.problems().isEmpty(),
+ qPrintable(QStringLiteral("'%1' warned").arg(testCase.first)));
+ }
+}
+
+void TestConfig::syncOnExitWarnsOnGarbage()
+{
+ // Silently falling back would change what happens to unsynced work without
+ // telling the user, so a typo has to be named.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral("[general]\n"
+ "sync_on_exit=maybe\n")));
+ QCOMPARE(config.syncOnExit(), Config::SyncOnExit::Ask);
+ QVERIFY(!config.problems().isEmpty());
+}
+
void TestConfig::extraMimetypesAppendToBuiltins()
{
QTemporaryDir dir;