From ff8eacfd9f4ff4462e6b153f4b9da72d239ddb60 Mon Sep 17 00:00:00 2001 From: Sotiris Nanopoulos Date: Tue, 29 Jun 2021 16:20:59 -0700 Subject: [PATCH] Increase common/common coverage Signed-off-by: Sotiris Nanopoulos --- source/common/common/regex.cc | 26 -------------------------- test/common/common/stl_helpers_test.cc | 8 ++++++++ test/per_file_coverage.sh | 2 +- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/source/common/common/regex.cc b/source/common/common/regex.cc index 1f1aa4cc4a572..6b2e0050b487b 100644 --- a/source/common/common/regex.cc +++ b/source/common/common/regex.cc @@ -15,32 +15,6 @@ namespace Envoy { namespace Regex { namespace { -class CompiledStdMatcher : public CompiledMatcher { -public: - CompiledStdMatcher(std::regex&& regex) : regex_(std::move(regex)) {} - - // CompiledMatcher - bool match(absl::string_view value) const override { - try { - return std::regex_match(value.begin(), value.end(), regex_); - } catch (const std::regex_error& e) { - return false; - } - } - - // CompiledMatcher - std::string replaceAll(absl::string_view value, absl::string_view substitution) const override { - try { - return std::regex_replace(std::string(value), regex_, std::string(substitution)); - } catch (const std::regex_error& e) { - return std::string(value); - } - } - -private: - const std::regex regex_; -}; - class CompiledGoogleReMatcher : public CompiledMatcher { public: CompiledGoogleReMatcher(const envoy::type::matcher::v3::RegexMatcher& config) diff --git a/test/common/common/stl_helpers_test.cc b/test/common/common/stl_helpers_test.cc index 8f4b297c74055..4123ec9a0548a 100644 --- a/test/common/common/stl_helpers_test.cc +++ b/test/common/common/stl_helpers_test.cc @@ -22,4 +22,12 @@ TEST(StlHelpersTest, AccumulateToString) { [](const int& i) { return std::to_string(i); })); } +TEST(StlHelpersTest, ContainsReferenceTest) { + std::string str1{"1"}; + std::vector> numbers{str1}; + EXPECT_TRUE(containsReference(numbers, str1)); + std::string str2{"2"}; + EXPECT_FALSE(containsReference(numbers, str2)); +} + } // namespace Envoy diff --git a/test/per_file_coverage.sh b/test/per_file_coverage.sh index 24a37e150474d..a29182fe7bf7a 100755 --- a/test/per_file_coverage.sh +++ b/test/per_file_coverage.sh @@ -6,7 +6,7 @@ declare -a KNOWN_LOW_COVERAGE=( "source/common:96.3" # Raise when QUIC coverage goes up "source/common/api:75.3" "source/common/api/posix:73.9" -"source/common/common:96.2" +"source/common/common:96.3" "source/common/common/posix:94.1" "source/common/crypto:0.0" "source/common/event:94.2" # Emulated edge events guards don't report LCOV