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

Method getTCCall

lib/tcanalysis/GoogleTestCallWriter.cpp:6–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4using namespace ftg;
5
6std::string GoogleTestCallWriter::getTCCall(const Unittest &TC,
7 std::string Indent) const {
8 const auto *TCTestBody = TC.getTestBody();
9 if (!TCTestBody)
10 return "";
11
12 auto GtestClassName = TCTestBody->getClassName();
13 if (GtestClassName.empty())
14 return "";
15
16 std::string TestInstanceName = "Fuzzer";
17 std::map<std::string, std::string> ClassMap; // ClassName:InstanceName
18
19 for (const auto &TestFunc : TC.getTestSequence()) {
20 if (!TestFunc.isEnvironment() || TestFunc.getClassName().empty())
21 continue;
22 auto ClassName = TestFunc.getClassName();
23 ClassMap[ClassName] = getInstanceNameFromClass(ClassName);
24 }
25 ClassMap[FuzzGtestClassName] = TestInstanceName;
26
27 auto Result =
28 getGtestFuzzClassDeclString(GtestClassName, TC.getTestSequence(), Indent);
29
30 for (auto ClassDefInfo : ClassMap)
31 Result += (Indent + ClassDefInfo.first + " " + ClassDefInfo.second + ";\n");
32
33 bool CallRunTestFlag = false;
34 for (const auto &TestFunc : TC.getTestSequence()) {
35 if (TestFunc.isEnvironment()) {
36 Result += (Indent + ClassMap[TestFunc.getClassName()] + "." +
37 TestFunc.getFunctionName() + "();\n");
38 } else if (!CallRunTestFlag) {
39 CallRunTestFlag = true;
40 Result +=
41 (Indent + TestInstanceName + "." + FuzzGtestMethodName + "();\n");
42 }
43 }
44
45 return Result;
46}
47
48std::string GoogleTestCallWriter::getGtestFuzzClassDeclString(
49 const std::string &ParentClassName,

Callers

nothing calls this directly

Calls 6

getClassNameMethod · 0.80
emptyMethod · 0.80
getTestSequenceMethod · 0.80
isEnvironmentMethod · 0.80
getTestBodyMethod · 0.45
getFunctionNameMethod · 0.45

Tested by

no test coverage detected