1 //===-- ScanfMatcher.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_SCANF_MATCHER_H 10 #define LLVM_LIBC_UTILS_UNITTEST_SCANF_MATCHER_H 11 12 #include "src/__support/macros/config.h" 13 #include "src/stdio/scanf_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<scanf_core::FormatSection> { 20 scanf_core::FormatSection expected; 21 scanf_core::FormatSection actual; 22 23 public: FormatSectionMatcher(scanf_core::FormatSection expectedValue)24 FormatSectionMatcher(scanf_core::FormatSection expectedValue) 25 : expected(expectedValue) {} 26 27 bool match(scanf_core::FormatSection actualValue); 28 29 void explainError() override; 30 }; 31 32 } // namespace testing 33 } // namespace LIBC_NAMESPACE_DECL 34 35 #define EXPECT_SFORMAT_EQ(expected, actual) \ 36 EXPECT_THAT(actual, LIBC_NAMESPACE::testing::FormatSectionMatcher(expected)) 37 38 #define ASSERT_SFORMAT_EQ(expected, actual) \ 39 ASSERT_THAT(actual, LIBC_NAMESPACE::testing::FormatSectionMatcher(expected)) 40 41 #endif // LLVM_LIBC_UTILS_UNITTEST_SCANF_MATCHER_H 42