| 4 | using namespace ftg; |
| 5 | |
| 6 | std::string TCTCallWriter::getTCCall(const Unittest &TC, |
| 7 | std::string Indent) const { |
| 8 | std::string PreTestFunc, TestMainFunc, PostTestFunc; |
| 9 | bool PreAction = true; |
| 10 | for (const auto &TestFunc : TC.getTestSequence()) { |
| 11 | if (TestFunc.getName().empty()) |
| 12 | continue; |
| 13 | |
| 14 | if (TestFunc.isTestBody()) { |
| 15 | TestMainFunc = TestFunc.getName() + "();"; |
| 16 | PreAction = false; |
| 17 | continue; |
| 18 | } |
| 19 | |
| 20 | if (PreAction) { |
| 21 | PreTestFunc = TestFunc.getName() + "();"; |
| 22 | continue; |
| 23 | } |
| 24 | |
| 25 | PostTestFunc = TestFunc.getName() + "();"; |
| 26 | } |
| 27 | |
| 28 | std::string Result; |
| 29 | if (!PreTestFunc.empty()) |
| 30 | Result += Indent + PreTestFunc + "\n"; |
| 31 | if (!TestMainFunc.empty()) |
| 32 | Result += Indent + TestMainFunc + "\n"; |
| 33 | if (!PostTestFunc.empty()) |
| 34 | Result += Indent + PostTestFunc + "\n"; |
| 35 | return Result; |
| 36 | } |