fixup! [M120 Migration] Notify media device state to webbrowser
[platform/framework/web/chromium-efl.git] / base / traits_bag_unittest.nc
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.
4
5 // This is a "No Compile Test" suite.
6 // http://dev.chromium.org/developers/testing/no-compile-tests
7
8 #include "base/traits_bag.h"
9
10 namespace base {
11
12 enum class RequiredTrait {
13   A,
14   B,
15   C
16 };
17
18 struct BooleanTrait {};
19
20 struct NotAValidTrait {};
21
22 struct TestTraits {
23   // List of traits that are valid inputs for the constructor below.
24   struct ValidTrait {
25     ValidTrait(RequiredTrait);
26     ValidTrait(BooleanTrait);
27   };
28
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...>()) {}
35
36   const RequiredTrait required_trait;
37   const bool boolean_trait;
38 };
39
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(),
48                                BooleanTrait()};
49 #endif
50
51 }  // namespace base