132a6e48fSopenharmony_ci/*
232a6e48fSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
332a6e48fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
432a6e48fSopenharmony_ci * you may not use this file except in compliance with the License.
532a6e48fSopenharmony_ci * You may obtain a copy of the License at
632a6e48fSopenharmony_ci *
732a6e48fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
832a6e48fSopenharmony_ci *
932a6e48fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1032a6e48fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1132a6e48fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1232a6e48fSopenharmony_ci * See the License for the specific language governing permissions and
1332a6e48fSopenharmony_ci * limitations under the License.
1432a6e48fSopenharmony_ci */
1532a6e48fSopenharmony_ci
1632a6e48fSopenharmony_ci#ifndef UTILS_INCLUDE_TEST_HEADER_H
1732a6e48fSopenharmony_ci#define UTILS_INCLUDE_TEST_HEADER_H
1832a6e48fSopenharmony_ci
1932a6e48fSopenharmony_ci#include "hilog/log.h"
2032a6e48fSopenharmony_ci
2132a6e48fSopenharmony_cinamespace OHOS {
2232a6e48fSopenharmony_cistatic inline ::OHOS::HiviewDFX::HiLogLabel TEST_HEADER_HILOG_LABEL = { LOG_CORE, 0, "TEST" };
2332a6e48fSopenharmony_ci#define WMT_CPRINTF(color, func, fmt, ...) \
2432a6e48fSopenharmony_ci    func (TEST_HEADER_HILOG_LABEL, "\033[" #color "m" "<%{public}d>" fmt "\033[0m", __LINE__, ##__VA_ARGS__)
2532a6e48fSopenharmony_ci#define WMTLOGI(color, fmt, ...) \
2632a6e48fSopenharmony_ci    WMT_CPRINTF(color, HiviewDFX::HiLog::Info, "%{public}s: " fmt, __func__, ##__VA_ARGS__)
2732a6e48fSopenharmony_ci
2832a6e48fSopenharmony_ci#define PART(part) WMTLOGI(33, part); if (const char *strPart = part)
2932a6e48fSopenharmony_ci#define STEP(desc) WMTLOGI(34, desc); if (const char *strDesc = desc)
3032a6e48fSopenharmony_ci
3132a6e48fSopenharmony_ci#define STEP_CONDITION(condition) strPart << ": " << strDesc << " (" << condition << ")"
3232a6e48fSopenharmony_ci
3332a6e48fSopenharmony_ci#define STEP_ASSERT_(l, r, func, opstr) ASSERT_##func(l, r) <<  STEP_CONDITION(#l " " opstr " " #r)
3432a6e48fSopenharmony_ci
3532a6e48fSopenharmony_ci#define STEP_ASSERT_EQ(l, r) STEP_ASSERT_(l, r, EQ, "==")
3632a6e48fSopenharmony_ci#define STEP_ASSERT_NE(l, r) STEP_ASSERT_(l, r, NE, "!=")
3732a6e48fSopenharmony_ci#define STEP_ASSERT_GE(l, r) STEP_ASSERT_(l, r, GE, ">=")
3832a6e48fSopenharmony_ci#define STEP_ASSERT_LE(l, r) STEP_ASSERT_(l, r, LE, "<=")
3932a6e48fSopenharmony_ci#define STEP_ASSERT_GT(l, r) STEP_ASSERT_(l, r, GT, ">")
4032a6e48fSopenharmony_ci#define STEP_ASSERT_LT(l, r) STEP_ASSERT_(l, r, LT, "<")
4132a6e48fSopenharmony_ci} // namespace OHOS
4232a6e48fSopenharmony_ci
4332a6e48fSopenharmony_ci#endif // UTILS_INCLUDE_TEST_HEADER_H
44