1 //===-- PrintfMatcher.h -----------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_UTILS_UNITTEST_PRINTF_MATCHER_H
10 #define LLVM_LIBC_UTILS_UNITTEST_PRINTF_MATCHER_H
12 #include "src/__support/macros/config.h"
13 #include "src/stdio/printf_core/core_structs.h"
14 #include "test/UnitTest/Test.h"
16 namespace LIBC_NAMESPACE_DECL
{
19 class FormatSectionMatcher
: public Matcher
<printf_core::FormatSection
> {
20 printf_core::FormatSection expected
;
21 printf_core::FormatSection actual
;
24 FormatSectionMatcher(printf_core::FormatSection expectedValue
)
25 : expected(expectedValue
) {}
27 bool match(printf_core::FormatSection actualValue
);
29 void explainError() override
;
32 } // namespace testing
33 } // namespace LIBC_NAMESPACE_DECL
35 #define EXPECT_PFORMAT_EQ(expected, actual) \
36 EXPECT_THAT(actual, LIBC_NAMESPACE::testing::FormatSectionMatcher(expected))
38 #define ASSERT_PFORMAT_EQ(expected, actual) \
39 ASSERT_THAT(actual, LIBC_NAMESPACE::testing::FormatSectionMatcher(expected))
41 #endif // LLVM_LIBC_UTILS_UNITTEST_PRINTF_MATCHER_H