Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/gtest/metaprogramming/test_logical.cpp
41145 views
1
/*
2
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#include "precompiled.hpp"
26
#include "metaprogramming/logical.hpp"
27
#include <type_traits>
28
29
class TestBoolConstant {
30
static_assert(BoolConstant<true>::value, "true");
31
static_assert(!BoolConstant<false>::value, "false");
32
};
33
34
class TestConjunction {
35
class A : public std::true_type {};
36
class B : public std::true_type {};
37
class C : public std::false_type {};
38
class D : public std::false_type {};
39
40
static_assert(Conjunction<>::value, "nullary value");
41
42
static_assert(Conjunction<A>::value, "true value");
43
static_assert(std::is_base_of<A, Conjunction<A>>::value, "true type");
44
45
static_assert(!Conjunction<C>::value, "false value");
46
static_assert(std::is_base_of<C, Conjunction<C>>::value, "false type");
47
48
static_assert(Conjunction<A, B>::value, "true/true value");
49
static_assert(std::is_base_of<B, Conjunction<A, B>>::value, "true/true type");
50
51
static_assert(!Conjunction<A, C>::value, "true/false value");
52
static_assert(std::is_base_of<C, Conjunction<A, C>>::value, "true/false type");
53
54
static_assert(!Conjunction<C, A>::value, "false/true value");
55
static_assert(std::is_base_of<C, Conjunction<C, A>>::value, "false/true type");
56
57
static_assert(!Conjunction<C, D>::value, "false/false value");
58
static_assert(std::is_base_of<C, Conjunction<C, D>>::value, "false/false type");
59
};
60
61
class TestDisjunction {
62
class A : public std::true_type {};
63
class B : public std::true_type {};
64
class C : public std::false_type {};
65
class D : public std::false_type {};
66
67
static_assert(!Disjunction<>::value, "nullary value");
68
69
static_assert(Disjunction<A>::value, "true value");
70
static_assert(std::is_base_of<A, Disjunction<A>>::value, "true type");
71
72
static_assert(!Disjunction<C>::value, "false value");
73
static_assert(std::is_base_of<C, Disjunction<C>>::value, "false type");
74
75
static_assert(Disjunction<A, B>::value, "true/true value");
76
static_assert(std::is_base_of<A, Disjunction<A, B>>::value, "true/true type");
77
78
static_assert(Disjunction<A, C>::value, "true/false value");
79
static_assert(std::is_base_of<A, Disjunction<A, C>>::value, "true/false type");
80
81
static_assert(Disjunction<C, A>::value, "false/true value");
82
static_assert(std::is_base_of<A, Disjunction<C, A>>::value, "false/true type");
83
84
static_assert(!Disjunction<C, D>::value, "false/false value");
85
static_assert(std::is_base_of<D, Disjunction<C, D>>::value, "false/false type");
86
};
87
88
class TestNegation {
89
static_assert(Negation<std::false_type>::value, "false -> true");
90
static_assert(!Negation<std::true_type>::value, "true -> false");
91
};
92
93