Fix emulator build error
[platform/framework/web/chromium-efl.git] / base / parameter_pack_unittest.cc
1 // Copyright 2019 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 #include "base/parameter_pack.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace base {
10
11 TEST(ParameterPack, AnyOf) {
12   static_assert(any_of({true, true, true}), "");
13   static_assert(any_of({false, false, true, false}), "");
14   static_assert(!any_of({false}), "");
15   static_assert(!any_of({false, false, false}), "");
16 }
17
18 TEST(ParameterPack, AllOf) {
19   static_assert(all_of({true, true, true}), "");
20   static_assert(!all_of({true, true, true, false}), "");
21   static_assert(!all_of({false}), "");
22   static_assert(!all_of({false, false}), "");
23 }
24
25 TEST(ParameterPack, Count) {
26   static_assert(count({1, 2, 2, 2, 2, 2, 3}, 2) == 5u, "");
27 }
28
29 TEST(ParameterPack, HasType) {
30   static_assert(ParameterPack<int, float, bool>::HasType<int>(), "");
31   static_assert(ParameterPack<int, float, bool>::HasType<bool>(), "");
32   static_assert(ParameterPack<int, float, bool>::HasType<bool>(), "");
33   static_assert(!ParameterPack<int, float, bool>::HasType<void*>(), "");
34 }
35
36 TEST(ParameterPack, OnlyHasType) {
37   static_assert(ParameterPack<int, int>::OnlyHasType<int>(), "");
38   static_assert(ParameterPack<int, int, int, int>::OnlyHasType<int>(), "");
39   static_assert(!ParameterPack<int, bool>::OnlyHasType<int>(), "");
40   static_assert(!ParameterPack<int, int, bool, int>::OnlyHasType<int>(), "");
41   static_assert(!ParameterPack<int, int, int>::OnlyHasType<bool>(), "");
42 }
43
44 TEST(ParameterPack, IsUniqueInPack) {
45   static_assert(ParameterPack<int, float, bool>::IsUniqueInPack<int>(), "");
46   static_assert(!ParameterPack<int, int, bool>::IsUniqueInPack<int>(), "");
47 }
48
49 TEST(ParameterPack, IndexInPack) {
50   static_assert(ParameterPack<int, float, bool>::IndexInPack<int>() == 0u, "");
51   static_assert(ParameterPack<int, float, bool>::IndexInPack<float>() == 1u,
52                 "");
53   static_assert(ParameterPack<int, float, bool>::IndexInPack<bool>() == 2u, "");
54   static_assert(
55       ParameterPack<int, float, bool>::IndexInPack<void*>() == pack_npos, "");
56 }
57
58 TEST(ParameterPack, NthType) {
59   static_assert(
60       std::is_same_v<int, ParameterPack<int, float, bool>::NthType<0>>, "");
61   static_assert(
62       std::is_same_v<float, ParameterPack<int, float, bool>::NthType<1>>, "");
63   static_assert(
64       std::is_same_v<bool, ParameterPack<int, float, bool>::NthType<2>>, "");
65 }
66
67 TEST(ParameterPack, IsAllSameType) {
68   static_assert(ParameterPack<int>::IsAllSameType(), "");
69   static_assert(ParameterPack<int, int, int>::IsAllSameType(), "");
70   static_assert(!ParameterPack<int, int, int, int, bool>::IsAllSameType(), "");
71 }
72
73 }  // namespace base