diff options
Diffstat (limited to 'lib/omittable.cpp')
-rw-r--r-- | lib/omittable.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/omittable.cpp b/lib/omittable.cpp new file mode 100644 index 00000000..245ae721 --- /dev/null +++ b/lib/omittable.cpp @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: 2021 Kitsune Ral <kitsune-ral@users.sf.net> +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include "omittable.h" + +// 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>()))>); |