xref: /aosp_15_r20/external/google-fruit/tests/meta/test_algos.py (revision a65addddcf69f38db5b288d787b6b7571a57bb8f)
1#!/usr/bin/env python3
2#  Copyright 2016 Google Inc. All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS-IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from absl.testing import parameterized
17from fruit_test_common import *
18
19COMMON_DEFINITIONS = '''
20    #define IN_FRUIT_CPP_FILE 1
21
22    #include "meta/common.h"
23    #include <fruit/impl/meta/algos.h>
24    '''
25
26class TestAlgos(parameterized.TestCase):
27    def test_HasDuplicates(self):
28        source = '''
29            int main() {
30              AssertNot(HasDuplicates(Vector<>));
31              AssertNot(HasDuplicates(Vector<Int<0>>));
32              AssertNot(HasDuplicates(Vector<Int<0>, Int<1>>));
33              Assert(HasDuplicates(Vector<Int<0>, Int<0>>));
34              Assert(HasDuplicates(Vector<Int<2>, Int<0>, Int<1>, Int<0>, Int<3>>));
35            }
36            '''
37        expect_success(
38            COMMON_DEFINITIONS,
39            source,
40            locals())
41
42if __name__ == '__main__':
43    absltest.main()
44