aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.match/test.cc
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-06-28 19:25:55 +0100
committerLexi Winter <lexi@le-fay.org>2025-06-28 19:25:55 +0100
commita2d7181700ac64b8e7a4472ec26dfa253b38f188 (patch)
tree23c5a9c8ec4089ac346e2e0f9391909c3089b66b /nihil.match/test.cc
parentf226d46ee02b57dd76a4793593aa8d66e1c58353 (diff)
downloadnihil-a2d7181700ac64b8e7a4472ec26dfa253b38f188.tar.gz
nihil-a2d7181700ac64b8e7a4472ec26dfa253b38f188.tar.bz2
split nihil into separate modules
Diffstat (limited to 'nihil.match/test.cc')
-rw-r--r--nihil.match/test.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/nihil.match/test.cc b/nihil.match/test.cc
new file mode 100644
index 0000000..7dd1c34
--- /dev/null
+++ b/nihil.match/test.cc
@@ -0,0 +1,34 @@
+/*
+ * This source code is released into the public domain.
+ */
+
+#include <string>
+#include <variant>
+
+#include <catch2/catch_test_macros.hpp>
+
+import nihil.match;
+
+TEST_CASE("match", "[nihil]")
+{
+ using namespace nihil;
+ using namespace std::literals;
+
+ auto v = std::variant<int, std::string>(42);
+
+ auto s = v | match {
+ [](int) { return "int"s; },
+ [](std::string const &) { return "string"s; }
+ };
+
+ REQUIRE(s == "int");
+
+ v = "test"s;
+
+ s = v | match {
+ [](int) { return "int"s; },
+ [](std::string const &) { return "string"s; }
+ };
+
+ REQUIRE(s == "string");
+}