Replace or remove some characters to meet gtest name convention (#13266)

### Description
To construct test name, replace whitespace to underscore and remove
parentheses

### Motivation and Context
gtest name only accepts '_' and alphanumeric
This commit is contained in:
Yi Zhang 2022-10-11 16:23:54 +08:00 committed by GitHub
parent febd5facce
commit cd2e8b306c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1131,9 +1131,12 @@ auto ExpandModelName = [](const ::testing::TestParamInfo<ModelTest::ParamType>&
std::replace(name.begin(), name.end(), '/', '_');
std::replace(name.begin(), name.end(), '\\', '_');
// in case there's whitespace in directory name
std::replace(name.begin(), name.end(), ' ', '_');
// Note: test name only accepts '_' and alphanumeric
// remove '.', '-', ':'
char chars[] = ".-:";
char chars[] = ".-:()";
for (unsigned int i = 0; i < strlen(chars); ++i) {
name.erase(std::remove(name.begin(), name.end(), chars[i]), name.end());
}