summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/UnitTest')
-rw-r--r--Swift/QtUI/UnitTest/QtUtilitiesTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/Swift/QtUI/UnitTest/QtUtilitiesTest.cpp b/Swift/QtUI/UnitTest/QtUtilitiesTest.cpp
new file mode 100644
index 0000000..45d2239
--- /dev/null
+++ b/Swift/QtUI/UnitTest/QtUtilitiesTest.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <QDateTime>
+#include <QLocale>
+
+#include <Swift/QtUI/QtUtilities.h>
+#include <Swift/QtUI/QtUtilities.cpp>
+
+TEST(QtUtilitiesTest, testDSTawareness) {
+ QLocale::setDefault(QLocale(QLocale::English, QLocale::Germany));
+
+ auto beforeDSTpoint = QDateTime(QDate(2017, 3, 26), QTime(0, 0));
+
+ ASSERT_EQ(23 * 60 * 60, QtUtilities::secondsToNextMidnight(beforeDSTpoint));
+}
+
+
+TEST(QtUtilitiesTest, testNoDSTChange) {
+ QLocale::setDefault(QLocale(QLocale::English, QLocale::Germany));
+
+ auto beforeDSTpoint = QDateTime(QDate(2017, 3, 23), QTime(0, 0));
+
+ ASSERT_EQ(24 * 60 * 60, QtUtilities::secondsToNextMidnight(beforeDSTpoint));
+}