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/stdio/printf_core/core_structs.h"
13 #include "utils/UnitTest/Test.h"
14 
15 #include <errno.h>
16 
17 namespace __llvm_libc {
18 namespace printf_core {
19 namespace testing {
20 
21 class FormatSectionMatcher
22     : public __llvm_libc::testing::Matcher<FormatSection> {
23   FormatSection expected;
24   FormatSection actual;
25 
26 public:
27   FormatSectionMatcher(FormatSection expectedValue) : expected(expectedValue) {}
28 
29   bool match(FormatSection actualValue);
30 
31   void explainError(testutils::StreamWrapper &stream) override;
32 };
33 
34 } // namespace testing
35 } // namespace printf_core
36 } // namespace __llvm_libc
37 
38 #define EXPECT_FORMAT_EQ(expected, actual)                                     \
39   EXPECT_THAT(actual, __llvm_libc::printf_core::testing::FormatSectionMatcher( \
40                           expected))
41 
42 #define ASSERT_FORMAT_EQ(expected, actual)                                     \
43   ASSERT_THAT(actual, __llvm_libc::printf_core::testing::FormatSectionMatcher( \
44                           expected))
45 
46 #endif // LLVM_LIBC_UTILS_UNITTEST_PRINTF_MATCHER_H
47