}
}
-static void parseCaseList (CaseTreeNode* root, std::istream& in)
+static void parseCaseList (CaseTreeNode* root, std::istream& in, bool reportDuplicates)
{
// \note Algorithm assumes that cases are sorted by groups, but will
// function fine, albeit more slowly, if that is not the case.
if (curName.empty())
throw std::invalid_argument("Empty test case name");
- if (nodeStack[stackPos]->hasChild(curName))
- throw std::invalid_argument("Duplicate test case");
-
- CaseTreeNode* const newChild = new CaseTreeNode(curName);
-
- try
- {
- nodeStack[stackPos]->addChild(newChild);
- }
- catch (...)
+ if (!nodeStack[stackPos]->hasChild(curName))
{
- delete newChild;
- throw;
+ CaseTreeNode* const newChild = new CaseTreeNode(curName);
+
+ try
+ {
+ nodeStack[stackPos]->addChild(newChild);
+ }
+ catch (...)
+ {
+ delete newChild;
+ throw;
+ }
}
+ else if (reportDuplicates)
+ throw std::invalid_argument("Duplicate test case");
curName.clear();
stackPos = 0;
if (in.peek() == '{')
parseCaseTrie(root, in);
else
- parseCaseList(root, in);
+ parseCaseList(root, in, true);
{
const int curChr = in.get();
{
fileStream.clear();
fileStream.seekg(0, fileStream.beg);
- parseCaseList(m_caseTree, fileStream);
+ parseCaseList(m_caseTree, fileStream, false);
}
}
}