aboutsummaryrefslogtreecommitdiff
path: root/autotests
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-01-28 21:28:47 +0100
committerGitHub <noreply@github.com>2022-01-28 21:28:47 +0100
commitb39b70bf90d816377b2873a5c2506bd256c0a00e (patch)
treed3ab6da61f0bd7d69bd66a63e450a6f4d85895f0 /autotests
parentcc9908e5159ed93a18eda9f9794a7c9fc7f67f27 (diff)
parent1747575321cda4fc11f90c2ffb2148a69d0d9946 (diff)
downloadlibquotient-b39b70bf90d816377b2873a5c2506bd256c0a00e.tar.gz
libquotient-b39b70bf90d816377b2873a5c2506bd256c0a00e.zip
Merge pull request #525 from quotient-im/kitsune/query-current-state
Move out current room state to its own class
Diffstat (limited to 'autotests')
-rw-r--r--autotests/CMakeLists.txt1
-rw-r--r--autotests/utiltests.cpp45
2 files changed, 46 insertions, 0 deletions
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 282ab036..9efab0d1 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -12,3 +12,4 @@ function(QUOTIENT_ADD_TEST)
endfunction()
quotient_add_test(NAME callcandidateseventtest)
+quotient_add_test(NAME utiltests)
diff --git a/autotests/utiltests.cpp b/autotests/utiltests.cpp
new file mode 100644
index 00000000..e3ec63d0
--- /dev/null
+++ b/autotests/utiltests.cpp
@@ -0,0 +1,45 @@
+// SPDX-FileCopyrightText: 2021 Kitsune Ral <kitsune-ral@users.sf.net>
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#include "omittable.h"
+
+#include <QtTest/QtTest>
+
+// compile-time Omittable<> tests
+using namespace Quotient;
+
+Omittable<int> testFn(bool) { return 0; }
+bool testFn2(int) { return false; }
+static_assert(
+ std::is_same_v<decltype(std::declval<Omittable<bool>>().then(testFn)),
+ Omittable<int>>);
+static_assert(
+ std::is_same_v<
+ decltype(std::declval<Omittable<bool>>().then_or(testFn, 0)), int>);
+static_assert(
+ std::is_same_v<decltype(std::declval<Omittable<bool>>().then(testFn)),
+ Omittable<int>>);
+static_assert(std::is_same_v<decltype(std::declval<Omittable<int>>()
+ .then(testFn2)
+ .then(testFn)),
+ Omittable<int>>);
+static_assert(std::is_same_v<decltype(std::declval<Omittable<bool>>()
+ .then(testFn)
+ .then_or(testFn2, false)),
+ bool>);
+
+constexpr auto visitTestFn(int, bool) { return false; }
+static_assert(
+ std::is_same_v<Omittable<bool>, decltype(lift(testFn2, Omittable<int>()))>);
+static_assert(std::is_same_v<Omittable<bool>,
+ decltype(lift(visitTestFn, Omittable<int>(),
+ Omittable<bool>()))>);
+
+class TestUtils : public QObject {
+ Q_OBJECT
+private Q_SLOTS:
+ // TODO
+};
+
+QTEST_APPLESS_MAIN(TestUtils)
+#include "utiltests.moc"