xref: /aosp_15_r20/external/tink/cc/core/template_util_test.cc (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1 // Copyright 2019 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 ///////////////////////////////////////////////////////////////////////////////
16 
17 #include "tink/core/template_util.h"
18 
19 namespace crypto {
20 namespace tink {
21 namespace internal {
22 
23 namespace {
24 class C0 {};
25 class C1 {};
26 class C2 {};
27 class C3 {};
28 class C4 {};
29 }  // namespace
30 
31 static_assert(!HasDuplicates<>::value, "");
32 static_assert(!HasDuplicates<C0>::value, "");
33 static_assert(!HasDuplicates<C0, C1>::value, "");
34 static_assert(!HasDuplicates<C0, C1, C2>::value, "");
35 static_assert(!HasDuplicates<C0, C1, C2, C3>::value, "");
36 
37 static_assert(HasDuplicates<C0, C0>::value, "");
38 static_assert(HasDuplicates<C0, C1, C0>::value, "");
39 static_assert(HasDuplicates<C0, C1, C1>::value, "");
40 static_assert(HasDuplicates<C0, C0, C1>::value, "");
41 static_assert(HasDuplicates<C0, C1, C2, C3, C1, C4>::value, "");
42 
43 static_assert(IndexOf<C0, List<C0, C1, C2, C3>>::value == 0, "");
44 static_assert(IndexOf<C1, List<C0, C1, C2, C3>>::value == 1, "");
45 static_assert(IndexOf<C2, List<C0, C1, C2, C3>>::value == 2, "");
46 static_assert(IndexOf<C3, List<C0, C1, C2, C3>>::value == 3, "");
47 
48 static_assert(IndexOf<C0, List<C0, C1, C2, C3, C1>>::value == 0, "");
49 static_assert(IndexOf<C1, List<C0, C1, C2, C3, C1>>::value == 1, "");
50 static_assert(IndexOf<C2, List<C0, C1, C2, C3, C1>>::value == 2, "");
51 static_assert(IndexOf<C3, List<C0, C1, C2, C3, C1>>::value == 3, "");
52 
53 }  // namespace internal
54 }  // namespace tink
55 }  // namespace crypto
56