MCPcopy Create free account
hub / github.com/Samsung/UTopia / TEST

Function TEST

tests/TestASTUtils.cpp:195–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195TEST(TestASTUtils, getTypeNameP) {
196
197 std::unique_ptr<ASTUnit> AST = tooling::buildASTFromCode(
198 "typedef struct A {} AA;\n"
199 "typedef struct {} BB;\n"
200 "void func(\n"
201 " struct A* P0, struct A *P1, struct A * P2, const struct A* P3,\n"
202 " const struct A *P4, const struct A * P5, struct A* const P6,\n"
203 " struct A *const P7, struct A * const P8, struct A const* P9,\n"
204 " struct A const *P10, struct A const * P11, AA* P12, AA *P13,\n"
205 " AA * P14, const AA* P15, const AA *P16, const AA * P17,\n"
206 " AA* const P18, AA *const P19, AA * const P20, AA const* P21,\n"
207 " AA const *P22, AA const * P23);\n"
208 "void func2(\n"
209 " BB* P0, BB *P1, BB * P2, const BB* P3, const BB *P4,\n"
210 " const BB * P5, BB* const P6, BB *const P7, BB * const P8,\n"
211 " BB const* P9, BB const *P10, BB const * P11);\n");
212
213 ASSERT_TRUE(AST);
214
215 for (auto Arg : getFunctionDecl(*AST, "func")->parameters()) {
216 QualType Ty = Arg->getType();
217 while (Ty->isPointerType()) {
218 Ty = Ty->getPointeeType();
219 }
220 EXPECT_EQ("A", getTypeName(*Ty->getAsTagDecl()));
221 }
222 for (auto Arg : getFunctionDecl(*AST, "func2")->parameters()) {
223 QualType Ty = Arg->getType();
224 while (Ty->isPointerType()) {
225 Ty = Ty->getPointeeType();
226 }
227 EXPECT_EQ("BB", getTypeName(*Ty->getAsTagDecl()));
228 }
229}
230
231TEST(TestASTUtils, getAsArrayTypeP) {
232

Callers

nothing calls this directly

Calls 7

getTypeNameFunction · 0.85
getAsArrayTypeFunction · 0.85
isPointerTypeMethod · 0.80
getPointeeTypeMethod · 0.80
getFunctionDeclFunction · 0.70
getTypeMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected