|
| 1 | +#include "codspeed.h" |
| 2 | +#include <gtest/gtest.h> |
| 3 | + |
| 4 | +// Manual definition (to avoid including it in the public header): |
| 5 | +std::string search_and_replace_between_brackets(std::string &text, |
| 6 | + const std::string &search, |
| 7 | + const std::string &replace); |
| 8 | + |
| 9 | +TEST(CodSpeedTest, TestSearchAndReplaceBetweenBracketsNamespace) { |
| 10 | + std::string no_brackets_input = |
| 11 | + "examples/google_benchmark/main.cpp::BM_rand_vector"; |
| 12 | + std::string no_brackets_output = |
| 13 | + "examples/google_benchmark/main.cpp::BM_rand_vector"; |
| 14 | + EXPECT_EQ( |
| 15 | + search_and_replace_between_brackets(no_brackets_input, "::", "\\:\\:"), |
| 16 | + no_brackets_output); |
| 17 | + |
| 18 | + std::string brackets_and_no_escaped_type_input = |
| 19 | + "examples/google_benchmark/" |
| 20 | + "template_bench.hpp::BM_Template1_Capture[two_type_test, int, double]"; |
| 21 | + std::string brackets_and_no_escaped_type_output = |
| 22 | + "examples/google_benchmark/" |
| 23 | + "template_bench.hpp::BM_Template1_Capture[two_type_test, int, double]"; |
| 24 | + EXPECT_EQ(search_and_replace_between_brackets( |
| 25 | + brackets_and_no_escaped_type_input, "::", "\\:\\:,"), |
| 26 | + brackets_and_no_escaped_type_output); |
| 27 | + |
| 28 | + std::string brackets_and_escaped_type_input = |
| 29 | + "examples/google_benchmark/" |
| 30 | + "template_bench.hpp::test::BM_Template[std::string]"; |
| 31 | + std::string brackets_and_escaped_type_output = |
| 32 | + "examples/google_benchmark/" |
| 33 | + "template_bench.hpp::test::BM_Template[std\\:\\:string]"; |
| 34 | + |
| 35 | + EXPECT_EQ(search_and_replace_between_brackets(brackets_and_escaped_type_input, |
| 36 | + "::", "\\:\\:"), |
| 37 | + brackets_and_escaped_type_output); |
| 38 | +} |
0 commit comments