Support underscores in test names

This commit is contained in:
Nikita Lisitsa 2020-11-25 10:08:21 +03:00
parent eda0701887
commit ea81ac987d

View file

@ -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))
{