• 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 PANDA_TOOLING_INSPECTOR_TEST_COMMON_H
17 #define PANDA_TOOLING_INSPECTOR_TEST_COMMON_H
18 
19 #include "gtest/gtest.h"
20 #include "gmock/gmock.h"
21 
22 #include <system_error>
23 
24 namespace panda::tooling::inspector::test {
25 
26 MATCHER(IsInteger, "")
27 {
28     if (static_cast<int>(arg) == arg) {
29         return true;
30     }
31 
32     *result_listener << arg << " is not an integer";
33     return false;
34 }
35 
IsOk(std::error_code ec)36 inline testing::AssertionResult IsOk(std::error_code ec)
37 {
38     return (ec == std::error_code()) ? testing::AssertionSuccess()
39                                      : testing::AssertionFailure() << ec << ": " << ec.message();
40 }
41 
42 }  // namespace panda::tooling::inspector::test
43 
44 #endif  // PANDA_TOOLING_INSPECTOR_TEST_COMMON_H
45