• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 REPORT_TEST
17 #define REPORT_TEST
18 
19 #include <gtest/gtest.h>
20 #include <hilog/log.h>
21 
22 #include "debug_logger.h"
23 #include "report.h"
24 #include "utilities.h"
25 
26 namespace OHOS {
27 namespace Developtools {
28 namespace HiPerf {
29 template<class T>
CompareNumberTest(T & lowValue,T & midValue,T & highValue,ReportKeyCompareFunction & compareFunction)30 void CompareNumberTest(T &lowValue, T &midValue, T &highValue,
31                        ReportKeyCompareFunction &compareFunction)
32 {
33     EXPECT_EQ(compareFunction(lowValue, lowValue) == 0, true);
34     EXPECT_EQ(compareFunction(lowValue, midValue) < 0, true);
35     EXPECT_EQ(compareFunction(lowValue, highValue) < 0, true);
36     EXPECT_EQ(compareFunction(highValue, midValue) > 0, true);
37     EXPECT_EQ(compareFunction(highValue, lowValue) > 0, true);
38 }
39 
40 template<class T>
CompareStringTest(T & lowValue,T & midValue,T & highValue,ReportKeyCompareFunction & compareFunction)41 void CompareStringTest(T &lowValue, T &midValue, T &highValue,
42                        ReportKeyCompareFunction &compareFunction)
43 {
44     EXPECT_EQ(compareFunction(lowValue, lowValue) == 0, true);
45     EXPECT_EQ(compareFunction(lowValue, midValue) < 0, true);
46     EXPECT_EQ(compareFunction(lowValue, highValue) < 0, true);
47     EXPECT_EQ(compareFunction(highValue, midValue) > 0, true);
48     EXPECT_EQ(compareFunction(highValue, lowValue) > 0, true);
49 }
50 } // namespace HiPerf
51 } // namespace Developtools
52 } // namespace OHOS
53 
54 #endif // REPORT_TEST
55