-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathobs.which.cpp
More file actions
68 lines (53 loc) · 1.42 KB
/
obs.which.cpp
File metadata and controls
68 lines (53 loc) · 1.42 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Eggs.Variant
//
// Copyright Agustin K-ballo Berge, Fusion Fenix 2014-2018
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <eggs/variant.hpp>
#include <string>
#include <eggs/variant/detail/config/prefix.hpp>
#include "catch.hpp"
#include "constexpr.hpp"
TEST_CASE("variant<Ts...>::which()", "[variant.obs]")
{
// non-empty
{
eggs::variant<int, std::string> const v(42);
CHECK(v.which() == 0);
CHECK(noexcept(v.which()) == true);
#if EGGS_CXX11_HAS_CONSTEXPR
// constexpr
{
constexpr eggs::variant<int, Constexpr> v(42);
constexpr std::size_t vw = v.which();
}
#endif
}
// empty
{
eggs::variant<int, std::string> const v;
CHECK(v.which() == eggs::variant_npos);
CHECK(noexcept(v.which()) == true);
#if EGGS_CXX11_HAS_CONSTEXPR
// constexpr
{
constexpr eggs::variant<int, Constexpr> v;
constexpr std::size_t vw = v.which();
}
#endif
}
}
TEST_CASE("variant<>::which()", "[variant.obs]")
{
eggs::variant<> const v;
CHECK(v.which() == eggs::variant_npos);
CHECK(noexcept(v.which()) == true);
#if EGGS_CXX11_HAS_CONSTEXPR
// constexpr
{
constexpr eggs::variant<> v;
constexpr std::size_t vw = v.which();
}
#endif
}