1/*
2 * Copyright (c) 2021 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 UTILS_INCLUDE_TEST_HEADER_H
17#define UTILS_INCLUDE_TEST_HEADER_H
18
19#include "hilog/log.h"
20
21namespace OHOS {
22static inline ::OHOS::HiviewDFX::HiLogLabel TEST_HEADER_HILOG_LABEL = { LOG_CORE, 0, "TEST" };
23#define WMT_CPRINTF(color, func, fmt, ...) \
24    func (TEST_HEADER_HILOG_LABEL, "\033[" #color "m" "<%{public}d>" fmt "\033[0m", __LINE__, ##__VA_ARGS__)
25#define WMTLOGI(color, fmt, ...) \
26    WMT_CPRINTF(color, HiviewDFX::HiLog::Info, "%{public}s: " fmt, __func__, ##__VA_ARGS__)
27
28#define PART(part) WMTLOGI(33, part); if (const char *strPart = part)
29#define STEP(desc) WMTLOGI(34, desc); if (const char *strDesc = desc)
30
31#define STEP_CONDITION(condition) strPart << ": " << strDesc << " (" << condition << ")"
32
33#define STEP_ASSERT_(l, r, func, opstr) ASSERT_##func(l, r) <<  STEP_CONDITION(#l " " opstr " " #r)
34
35#define STEP_ASSERT_EQ(l, r) STEP_ASSERT_(l, r, EQ, "==")
36#define STEP_ASSERT_NE(l, r) STEP_ASSERT_(l, r, NE, "!=")
37#define STEP_ASSERT_GE(l, r) STEP_ASSERT_(l, r, GE, ">=")
38#define STEP_ASSERT_LE(l, r) STEP_ASSERT_(l, r, LE, "<=")
39#define STEP_ASSERT_GT(l, r) STEP_ASSERT_(l, r, GT, ">")
40#define STEP_ASSERT_LT(l, r) STEP_ASSERT_(l, r, LT, "<")
41} // namespace OHOS
42
43#endif // UTILS_INCLUDE_TEST_HEADER_H
44