Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek Bevendorff <janek@jbev.net>2018-01-24 15:22:20 +0300
committerJanek Bevendorff <janek@jbev.net>2018-01-24 15:32:37 +0300
commit7a6850d5fe38b4e19f12d0dc658c8b05ad0ea3bb (patch)
tree2a0ba9edb265861c423e439abe05e8f3ce8bb9d8 /tests/TestGlobal.h
parent6e2500385c8e00c3abe0d903625b23334411c5d4 (diff)
Move useful QTest template specializations to global header file
Fix KDBX test linker errors on Windows
Diffstat (limited to 'tests/TestGlobal.h')
-rw-r--r--tests/TestGlobal.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/TestGlobal.h b/tests/TestGlobal.h
new file mode 100644
index 000000000..017fbd5f9
--- /dev/null
+++ b/tests/TestGlobal.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 or (at your option)
+ * version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef KEEPASSXC_TESTGLOBAL_H
+#define KEEPASSXC_TESTGLOBAL_H
+
+#include "core/Uuid.h"
+#include "core/Group.h"
+
+#include <QTest>
+#include <QDateTime>
+
+namespace QTest {
+
+template<>
+inline char* toString(const Uuid& uuid)
+{
+ QByteArray ba = "Uuid(";
+ ba += uuid.toHex().toLatin1().constData();
+ ba += ")";
+ return qstrdup(ba.constData());
+}
+
+template<>
+inline char* toString(const Group::TriState& triState)
+{
+ QString value;
+
+ if (triState == Group::Inherit) {
+ value = "null";
+ } else if (triState == Group::Enable) {
+ value = "true";
+ } else {
+ value = "false";
+ }
+
+ return qstrdup(value.toLocal8Bit().constData());
+}
+
+} // namespace QTest
+
+
+namespace Test {
+
+inline QDateTime datetime(int year, int month, int day, int hour, int min, int second)
+{
+ return QDateTime(
+ QDate(year, month, day),
+ QTime(hour, min, second),
+ Qt::UTC);
+}
+
+} // namespace Test
+
+#endif //KEEPASSXC_TESTGLOBAL_H