| 1 | //===-- PrintfMatcher.h -----------------------------------------*- C++ -*-===// |
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef LLVM_LIBC_UTILS_UNITTEST_PRINTF_MATCHER_H |
| 10 | #define LLVM_LIBC_UTILS_UNITTEST_PRINTF_MATCHER_H |
| 11 | |
| 12 | #include "src/__support/macros/config.h" |
| 13 | #include "src/stdio/printf_core/core_structs.h" |
| 14 | #include "test/UnitTest/Test.h" |
| 15 | |
| 16 | namespace LIBC_NAMESPACE_DECL { |
| 17 | namespace testing { |
| 18 | |
| 19 | class FormatSectionMatcher : public Matcher<printf_core::FormatSection> { |
| 20 | printf_core::FormatSection expected; |
| 21 | printf_core::FormatSection actual; |
| 22 | |
| 23 | public: |
| 24 | FormatSectionMatcher(printf_core::FormatSection expectedValue) |
| 25 | : expected(expectedValue) {} |
| 26 | |
| 27 | bool match(printf_core::FormatSection actualValue); |
| 28 | |
| 29 | void explainError() override; |
| 30 | }; |
| 31 | |
| 32 | } // namespace testing |
| 33 | } // namespace LIBC_NAMESPACE_DECL |
| 34 | |
| 35 | #define EXPECT_PFORMAT_EQ(expected, actual) \ |
| 36 | EXPECT_THAT(actual, LIBC_NAMESPACE::testing::FormatSectionMatcher(expected)) |
| 37 | |
| 38 | #define ASSERT_PFORMAT_EQ(expected, actual) \ |
| 39 | ASSERT_THAT(actual, LIBC_NAMESPACE::testing::FormatSectionMatcher(expected)) |
| 40 | |
| 41 | #endif // LLVM_LIBC_UTILS_UNITTEST_PRINTF_MATCHER_H |
| 42 | |