summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeGUI/QCMakePresetTest.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-09-29 14:17:47 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-10-05 13:49:59 (GMT)
commita4382f72d7fb924f9649ae352d70a36df2d662a8 (patch)
tree15855284a47a3f3ab4a14f945559266ebabbb0a5 /Tests/CMakeGUI/QCMakePresetTest.cxx
parent8617479061039e2b357b7efc922f1b88648dce42 (diff)
downloadCMake-a4382f72d7fb924f9649ae352d70a36df2d662a8.zip
CMake-a4382f72d7fb924f9649ae352d70a36df2d662a8.tar.gz
CMake-a4382f72d7fb924f9649ae352d70a36df2d662a8.tar.bz2
CMake GUI: Add presets functionality
Diffstat (limited to 'Tests/CMakeGUI/QCMakePresetTest.cxx')
-rw-r--r--Tests/CMakeGUI/QCMakePresetTest.cxx82
1 files changed, 82 insertions, 0 deletions
diff --git a/Tests/CMakeGUI/QCMakePresetTest.cxx b/Tests/CMakeGUI/QCMakePresetTest.cxx
new file mode 100644
index 0000000..8fd07e7
--- /dev/null
+++ b/Tests/CMakeGUI/QCMakePresetTest.cxx
@@ -0,0 +1,82 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "QCMakePresetTest.h"
+
+#include <utility>
+
+#include "QCMakePreset.h"
+#include <QtTest>
+
+namespace {
+QCMakePreset makePreset()
+{
+ return QCMakePreset{
+ /*name=*/"name",
+ /*displayName=*/"displayName",
+ /*description=*/"description",
+ /*generator=*/"generator",
+ /*architecture=*/"architecture",
+ /*toolset=*/"toolset",
+ /*setGenConfig=*/true,
+ /*enabled=*/true,
+ };
+}
+
+template <typename T, typename U>
+QCMakePreset makePreset(T QCMakePreset::*field, U&& value)
+{
+ auto preset = makePreset();
+ preset.*field = std::forward<U>(value);
+ return preset;
+}
+}
+
+void QCMakePresetTest::equality()
+{
+ QFETCH(QCMakePreset, rhs);
+ QFETCH(bool, equal);
+ QFETCH(bool, lt);
+ QFETCH(bool, gt);
+
+ auto lhs = makePreset();
+ QVERIFY((lhs == rhs) == equal);
+ QVERIFY((lhs != rhs) == !equal);
+ QVERIFY((lhs < rhs) == lt);
+ QVERIFY((lhs >= rhs) == !lt);
+ QVERIFY((lhs > rhs) == gt);
+ QVERIFY((lhs <= rhs) == !gt);
+}
+
+void QCMakePresetTest::equality_data()
+{
+ QTest::addColumn<QCMakePreset>("rhs");
+ QTest::addColumn<bool>("equal");
+ QTest::addColumn<bool>("lt");
+ QTest::addColumn<bool>("gt");
+
+ QTest::newRow("equal") << makePreset() << true << false << false;
+ QTest::newRow("name") << makePreset(&QCMakePreset::name, "other-name")
+ << false << true << false;
+ QTest::newRow("displayName")
+ << makePreset(&QCMakePreset::displayName, "other-displayName") << false
+ << true << false;
+ QTest::newRow("description")
+ << makePreset(&QCMakePreset::description, "other-description") << false
+ << true << false;
+ QTest::newRow("generator")
+ << makePreset(&QCMakePreset::generator, "other-generator") << false << true
+ << false;
+ QTest::newRow("architecture")
+ << makePreset(&QCMakePreset::architecture, "other-architecture") << false
+ << true << false;
+ QTest::newRow("toolset") << makePreset(&QCMakePreset::toolset,
+ "other-toolset")
+ << false << false << true;
+ QTest::newRow("setGenConfig")
+ << makePreset(&QCMakePreset::setGenConfig, false) << false << false
+ << true;
+ QTest::newRow("enabled") << makePreset(&QCMakePreset::enabled, false)
+ << false << false << true;
+}
+
+QTEST_MAIN(QCMakePresetTest)