| 1 | //===-- DumpASTTests.cpp ----------------------------------------*- 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 | #include "TweakTesting.h" |
| 10 | #include "gmock/gmock.h" |
| 11 | #include "gtest/gtest.h" |
| 12 | |
| 13 | using ::testing::AllOf; |
| 14 | using ::testing::HasSubstr; |
| 15 | using ::testing::StartsWith; |
| 16 | |
| 17 | namespace clang { |
| 18 | namespace clangd { |
| 19 | namespace { |
| 20 | |
| 21 | TWEAK_TEST(DumpAST); |
| 22 | |
| 23 | TEST_F(DumpASTTest, Test) { |
| 24 | EXPECT_AVAILABLE("^int f^oo() { re^turn 2 ^+ 2; }" ); |
| 25 | EXPECT_UNAVAILABLE("/*c^omment*/ int foo() { return 2 ^ + 2; }" ); |
| 26 | EXPECT_THAT(apply("int x = 2 ^+ 2;" ), |
| 27 | AllOf(StartsWith("message:" ), HasSubstr("BinaryOperator" ), |
| 28 | HasSubstr("'+'" ), HasSubstr("|-IntegerLiteral" ), |
| 29 | HasSubstr("<col:9> 'int' 2\n`-IntegerLiteral" ), |
| 30 | HasSubstr("<col:13> 'int' 2" ))); |
| 31 | } |
| 32 | |
| 33 | } // namespace |
| 34 | } // namespace clangd |
| 35 | } // namespace clang |
| 36 | |