xref: /llvm-project/clang/unittests/Tooling/Syntax/SynthesisTest.cpp (revision 4c14ee61b73746b314d83e7c52e03d6527b78105)
1 //===- SynthesisTest.cpp --------------------------------------------------===//
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 // This file tests synthesis API for syntax trees.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "TreeTestBase.h"
14 #include "clang/Tooling/Syntax/BuildTree.h"
15 
16 using namespace clang;
17 using namespace clang::syntax;
18 
19 namespace {
20 
21 INSTANTIATE_TEST_CASE_P(SyntaxTreeTests, SyntaxTreeTest,
22                         ::testing::ValuesIn(allTestClangConfigs()), );
23 
24 TEST_P(SyntaxTreeTest, Leaf_Punctuation) {
25   buildTree("", GetParam());
26 
27   auto *C = syntax::createPunctuation(*Arena, tok::comma);
28   ASSERT_NE(C, nullptr);
29   EXPECT_EQ(C->getToken()->kind(), tok::comma);
30   EXPECT_TRUE(C->canModify());
31   EXPECT_FALSE(C->isOriginal());
32   EXPECT_TRUE(C->isDetached());
33 }
34 
35 TEST_P(SyntaxTreeTest, Statement_Empty) {
36   buildTree("", GetParam());
37 
38   auto *S = syntax::createEmptyStatement(*Arena);
39   ASSERT_NE(S, nullptr);
40   EXPECT_TRUE(S->canModify());
41   EXPECT_FALSE(S->isOriginal());
42   EXPECT_TRUE(S->isDetached());
43 }
44 } // namespace
45