Path: blob/master/test/hotspot/gtest/metaprogramming/test_logical.cpp
41145 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "metaprogramming/logical.hpp"26#include <type_traits>2728class TestBoolConstant {29static_assert(BoolConstant<true>::value, "true");30static_assert(!BoolConstant<false>::value, "false");31};3233class TestConjunction {34class A : public std::true_type {};35class B : public std::true_type {};36class C : public std::false_type {};37class D : public std::false_type {};3839static_assert(Conjunction<>::value, "nullary value");4041static_assert(Conjunction<A>::value, "true value");42static_assert(std::is_base_of<A, Conjunction<A>>::value, "true type");4344static_assert(!Conjunction<C>::value, "false value");45static_assert(std::is_base_of<C, Conjunction<C>>::value, "false type");4647static_assert(Conjunction<A, B>::value, "true/true value");48static_assert(std::is_base_of<B, Conjunction<A, B>>::value, "true/true type");4950static_assert(!Conjunction<A, C>::value, "true/false value");51static_assert(std::is_base_of<C, Conjunction<A, C>>::value, "true/false type");5253static_assert(!Conjunction<C, A>::value, "false/true value");54static_assert(std::is_base_of<C, Conjunction<C, A>>::value, "false/true type");5556static_assert(!Conjunction<C, D>::value, "false/false value");57static_assert(std::is_base_of<C, Conjunction<C, D>>::value, "false/false type");58};5960class TestDisjunction {61class A : public std::true_type {};62class B : public std::true_type {};63class C : public std::false_type {};64class D : public std::false_type {};6566static_assert(!Disjunction<>::value, "nullary value");6768static_assert(Disjunction<A>::value, "true value");69static_assert(std::is_base_of<A, Disjunction<A>>::value, "true type");7071static_assert(!Disjunction<C>::value, "false value");72static_assert(std::is_base_of<C, Disjunction<C>>::value, "false type");7374static_assert(Disjunction<A, B>::value, "true/true value");75static_assert(std::is_base_of<A, Disjunction<A, B>>::value, "true/true type");7677static_assert(Disjunction<A, C>::value, "true/false value");78static_assert(std::is_base_of<A, Disjunction<A, C>>::value, "true/false type");7980static_assert(Disjunction<C, A>::value, "false/true value");81static_assert(std::is_base_of<A, Disjunction<C, A>>::value, "false/true type");8283static_assert(!Disjunction<C, D>::value, "false/false value");84static_assert(std::is_base_of<D, Disjunction<C, D>>::value, "false/false type");85};8687class TestNegation {88static_assert(Negation<std::false_type>::value, "false -> true");89static_assert(!Negation<std::true_type>::value, "true -> false");90};919293