blob: 6cc0e275964bd3ef9b224b2b45b9f65b2cda976b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// This source code is released into the public domain.
#include <catch2/catch_test_macros.hpp>
import nihil.std;
import nihil.util;
namespace {
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");
}
} // anonymous namespace
|