1 //
2 // Copyright (c) 2017 The Khronos Group Inc.
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 //
16 #ifndef TEST_COMMON_AUTOTEST_TEST_SUITE_HPP
17 #define TEST_COMMON_AUTOTEST_TEST_SUITE_HPP
18 
19 #include <vector>
20 #include <string>
21 
22 namespace autotest {
23 
24 struct test_suite {
test_suiteautotest::test_suite25     test_suite(const std::string& name)
26         : name(name)
27     {
28 
29     }
30 
addautotest::test_suite31     void add(const test_definition& td)
32     {
33         test_defs.push_back(td);
34     }
35 
36     // List of test definitions
37     std::vector<test_definition> test_defs;
38     // Test suite name
39     const std::string name;
40 
global_test_suiteautotest::test_suite41     static test_suite& global_test_suite()
42     {
43         static test_suite global_test_suite("global");
44         return global_test_suite;
45     }
46 };
47 
48 namespace detail {
49 
50 struct test_case_registration
51 {
test_case_registrationautotest::detail::test_case_registration52     test_case_registration(const std::string& name, const basefn ptr)
53     {
54         ::autotest::test_suite::global_test_suite().add(test_definition({ptr, strdup(name.c_str())}));
55     }
56 };
57 
58 } // end detail namespace
59 } // end autotest namespace
60 
61 #endif // TEST_COMMON_AUTOTEST_TEST_SUITE_HPP
62