1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This is a "No Compile Test" suite.
6 // http://dev.chromium.org/developers/testing/no-compile-tests
8 #include "base/traits_bag.h"
12 enum class RequiredTrait {
18 struct BooleanTrait {};
20 struct NotAValidTrait {};
23 // List of traits that are valid inputs for the constructor below.
25 ValidTrait(RequiredTrait);
26 ValidTrait(BooleanTrait);
29 template <class... ArgTypes,
30 class CheckArgumentsAreValid = std::enable_if_t<
31 trait_helpers::AreValidTraits<ValidTrait, ArgTypes...>::value>>
32 constexpr TestTraits(ArgTypes... args)
33 : required_trait(trait_helpers::GetEnum<RequiredTrait>(args...)),
34 boolean_trait(trait_helpers::HasTrait<BooleanTrait, ArgTypes...>()) {}
36 const RequiredTrait required_trait;
37 const bool boolean_trait;
40 #if defined(NCTEST_TRAITS_BAG_REQUIRED_TRAIT_NOT_SET) // [r"The traits bag is missing a required trait."]
41 constexpr TestTraits traits = {};
42 #elif defined(NCTEST_TRAITS_BAG_INVALID_TRAIT) // [r"no matching constructor for initialization of 'const TestTraits'"]
43 constexpr TestTraits traits = {RequiredTrait::A, NotAValidTrait{}};
44 #elif defined(NCTEST_TASK_TRAITS_MULTIPLE_REQUIRED_TRAIT) // [r"The traits bag contains multiple traits of the same type."]
45 constexpr TestTraits traits = {RequiredTrait::A, RequiredTrait::B};
46 #elif defined(NCTEST_TASK_TRAITS_REDUNDANT_BOOLEAN_TRAIT) // [r"The traits bag contains multiple traits of the same type."]
47 constexpr TestTraits traits = {RequiredTrait::A, BooleanTrait(),