@@ -14,21 +14,6 @@ struct SplitStringTestData
1414 size_t max_count;
1515 std::vector<opentelemetry::nostd::string_view> splits;
1616 size_t expected_number_strings;
17-
18- // When googletest registers parameterized tests, it uses this method to format the parameters.
19- // The default implementation prints hex dump of all bytes in the object. If there is any padding
20- // in these bytes, valgrind reports this as a warning - "Use of uninitialized bytes".
21- // See https://github.com/google/googletest/issues/3805.
22- friend void PrintTo (const SplitStringTestData& data, std::ostream* os) {
23- std::stringstream ss;
24- for (auto it = data.splits .begin (); it != data.splits .end (); it++) {
25- if (it != data.splits .begin ()) {
26- ss << " ," ;
27- }
28- ss << *it;
29- }
30- *os << " (" << data.input << " ," << data.separator << " ," << data.max_count << " ," << ss.str () << " ," << data.expected_number_strings << " )" ;
31- }
3217};
3318
3419const SplitStringTestData split_string_test_cases[] = {
@@ -50,27 +35,22 @@ const SplitStringTestData split_string_test_cases[] = {
5035 4 },
5136};
5237
53- // Test fixture
54- class SplitStringTestFixture : public ::testing::TestWithParam<SplitStringTestData>
55- {};
5638
57- TEST_P (SplitStringTestFixture, SplitsAsExpected )
39+ TEST (StringTest, SplitStringTest )
5840{
59- SplitStringTestData test_param = GetParam ();
60- std::vector<opentelemetry::nostd::string_view> fields{};
61- fields.reserve (test_param.expected_number_strings );
62- size_t got_splits_num = opentelemetry::trace::propagation::detail::SplitString (
63- test_param.input , test_param.separator , fields.data (), test_param.max_count );
64-
65- // Assert on the output
66- EXPECT_EQ (got_splits_num, test_param.expected_number_strings );
67- for (size_t i = 0 ; i < got_splits_num; i++)
68- {
69- // Checks for resulting strings in-order
70- EXPECT_EQ (fields[i], test_param.splits [i]);
41+ for (auto &test_param : split_string_test_cases) {
42+ std::vector<opentelemetry::nostd::string_view> fields{};
43+ fields.reserve (test_param.expected_number_strings );
44+ size_t got_splits_num = opentelemetry::trace::propagation::detail::SplitString (
45+ test_param.input , test_param.separator , fields.data (), test_param.max_count );
46+
47+ // Assert on the output
48+ EXPECT_EQ (got_splits_num, test_param.expected_number_strings );
49+ for (size_t i = 0 ; i < got_splits_num; i++)
50+ {
51+ // Checks for resulting strings in-order
52+ EXPECT_EQ (fields[i], test_param.splits [i]);
53+ }
7154 }
7255}
7356
74- INSTANTIATE_TEST_SUITE_P (SplitStringTestCases,
75- SplitStringTestFixture,
76- ::testing::ValuesIn (split_string_test_cases));
0 commit comments