blob: 239465108fe26ba85ce395e4aa9416694ca5e6a6 (
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.core;
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
|