diff options
author | Steven Moreland <smoreland@google.com> | 2019-10-29 14:20:00 -0700 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2019-10-29 14:21:08 -0700 |
commit | becd44e026ff67cfd3f102fbba543434f5bf5ed2 (patch) | |
tree | 0d229af245a457e4fcdbc24db409952fbe8f7c86 /gtest_helper | |
parent | 87610aded4ca0e000d143cb72bb1832070417d23 (diff) | |
download | libhidl-becd44e026ff67cfd3f102fbba543434f5bf5ed2.tar.gz |
libhidl_gtest_helpers -> libhidl_gtest_helper
Singular name is more common.
Bug: N/A
Test: N/A
Change-Id: I9995101c4fe0e7d1f4b0da4841538a472d07a8c0
Diffstat (limited to 'gtest_helper')
-rw-r--r-- | gtest_helper/hidl/GtestPrinter.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gtest_helper/hidl/GtestPrinter.h b/gtest_helper/hidl/GtestPrinter.h new file mode 100644 index 0000000..c9f5dd3 --- /dev/null +++ b/gtest_helper/hidl/GtestPrinter.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <gtest/gtest.h> + +namespace android { +namespace hardware { + +static inline std::string PrintInstanceNameToString( + const testing::TestParamInfo<std::string>& info) { + // test names need to be unique -> index prefix + std::string name = std::to_string(info.index) + "/" + info.param; + + for (size_t i = 0; i < name.size(); i++) { + // gtest test names must only contain alphanumeric characters + if (!std::isalnum(name[i])) name[i] = '_'; + } + + return name; +} + +} // namespace hardware +} // namespace android |