From 4483e8137a06292a699879c94943e558e702decb Mon Sep 17 00:00:00 2001 From: Derek Brown Date: Tue, 14 Jan 2020 18:23:30 -0800 Subject: [PATCH] Add additional valid characters to parameter names I feel as though the alphanumeric + `_` charset is too restrictive, especially when formatting complex objects into names. Added a few extra characters which will help with this. --- googletest/include/gtest/internal/gtest-param-util.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index ffa7d72c..e97343b9 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -633,6 +633,8 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { int line; }; typedef ::std::vector InstantiationContainer; + + static std::string validParamChars = "_-:/"; static bool IsValidParamName(const std::string& name) { // Check for empty string @@ -641,7 +643,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { // Check for invalid characters for (std::string::size_type index = 0; index < name.size(); ++index) { - if (!isalnum(name[index]) && name[index] != '_') + if (!isalnum(name[index]) && validParamChars.find(name[index]) == std::string::npos) return false; }