Support underscores in test names
This commit is contained in:
parent
eda0701887
commit
ea81ac987d
1 changed files with 17 additions and 2 deletions
|
|
@ -15,10 +15,25 @@ namespace psemek::test
|
|||
|
||||
static std::map<std::string, void(*)()> tests;
|
||||
|
||||
static std::string normalize(std::string name)
|
||||
{
|
||||
std::replace(name.begin(), name.end(), '_', '/');
|
||||
|
||||
for (std::size_t i = 0;;)
|
||||
{
|
||||
i = name.find("//", i);
|
||||
if (i == std::string::npos)
|
||||
break;
|
||||
name.replace(i, 2, "_");
|
||||
++i;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
void add_test_case(char const * name, void(*f)())
|
||||
{
|
||||
std::string pname(name);
|
||||
std::replace(pname.begin(), pname.end(), '_', '/');
|
||||
std::string pname = normalize(name);
|
||||
|
||||
if (tests.count(pname))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue