• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
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 #ifndef LIBARK_DEFECT_SCAN_AUX_TESTS_TEST_HELPER_H
17 #define LIBARK_DEFECT_SCAN_AUX_TESTS_TEST_HELPER_H
18 
19 #include "libpandabase/macros.h"
20 
21 namespace panda::defect_scan_aux::test {
22 class TestHelper {
23 public:
24     template <typename T1, typename T2>
ExpectEqual(const T1 & left,const T2 & right)25     inline static void ExpectEqual(const T1 &left, const T2 &right)
26     {
27         if (left != static_cast<T1>(right)) {
28             std::cerr << "ExpectEqual failed" << std::endl;
29             UNREACHABLE();
30         }
31     }
32 
33     template <typename T1, typename T2>
ExpectNotEqual(const T1 & left,const T2 & right)34     inline static void ExpectNotEqual(const T1 &left, const T2 &right)
35     {
36         if (left == static_cast<T2>(right)) {
37             std::cerr << "ExpectNotEqual failed" << std::endl;
38             UNREACHABLE();
39         }
40     }
41 
ExpectTrue(bool val)42     inline static void ExpectTrue(bool val)
43     {
44         if (!val) {
45             std::cerr << "ExpectTrue failed" << std::endl;
46             UNREACHABLE();
47         }
48     }
49 
ExpectFalse(bool val)50     inline static void ExpectFalse(bool val)
51     {
52         if (val) {
53             std::cerr << "ExpectFalse failed" << std::endl;
54             UNREACHABLE();
55         }
56     }
57 };
58 }  // namespace panda::defect_scan_aux::test
59 #endif  // LIBARK_DEFECT_SCAN_AUX_TESTS_TEST_HELPER_H