third_party/abseil-cpp/absl/strings/match_test.cc
Go to the documentation of this file.
1 // Copyright 2017 The Abseil Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "absl/strings/match.h"
16 
17 #include "gtest/gtest.h"
18 
19 namespace {
20 
21 TEST(MatchTest, StartsWith) {
22  const std::string s1("123\0abc", 7);
23  const absl::string_view a("foobar");
24  const absl::string_view b(s1);
25  const absl::string_view e;
36 }
37 
38 TEST(MatchTest, EndsWith) {
39  const std::string s1("123\0abc", 7);
40  const absl::string_view a("foobar");
41  const absl::string_view b(s1);
42  const absl::string_view e;
44  EXPECT_TRUE(absl::EndsWith(a, "bar"));
53 }
54 
55 TEST(MatchTest, Contains) {
56  absl::string_view a("abcdefg");
57  absl::string_view b("abcd");
58  absl::string_view c("efg");
59  absl::string_view d("gh");
65  EXPECT_TRUE(absl::StrContains("abc", ""));
67 }
68 
69 TEST(MatchTest, ContainsChar) {
70  absl::string_view a("abcdefg");
71  absl::string_view b("abcd");
76 
81 
84 }
85 
86 TEST(MatchTest, ContainsNull) {
87  const std::string s = "foo";
88  const char* cs = "foo";
89  const absl::string_view sv("foo");
90  const absl::string_view sv2("foo\0bar", 4);
91  EXPECT_EQ(s, "foo");
92  EXPECT_EQ(sv, "foo");
93  EXPECT_NE(sv2, "foo");
98 }
99 
100 TEST(MatchTest, EqualsIgnoreCase) {
101  std::string text = "the";
103 
109 }
110 
111 TEST(MatchTest, StartsWithIgnoreCase) {
117 }
118 
119 TEST(MatchTest, EndsWithIgnoreCase) {
120  EXPECT_TRUE(absl::EndsWithIgnoreCase("foo", "foo"));
123  EXPECT_FALSE(absl::EndsWithIgnoreCase("foo", "fooo"));
125 }
126 
127 } // namespace
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1970
test_evm.cs
cs
Definition: test_evm.py:8
absl::StartsWithIgnoreCase
bool StartsWithIgnoreCase(absl::string_view text, absl::string_view prefix) noexcept
Definition: abseil-cpp/absl/strings/match.cc:30
absl::StartsWith
bool StartsWith(absl::string_view text, absl::string_view prefix) noexcept
Definition: third_party/abseil-cpp/absl/strings/match.h:58
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
absl::FormatConversionChar::s
@ s
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
absl::FormatConversionChar::e
@ e
c
void c(T a)
Definition: miscompile_with_no_unique_address_test.cc:40
gen_server_registered_method_bad_client_test_body.text
def text
Definition: gen_server_registered_method_bad_client_test_body.py:50
TEST
#define TEST(name, init_size,...)
Definition: arena_test.cc:75
EXPECT_NE
#define EXPECT_NE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2028
absl::EqualsIgnoreCase
ABSL_NAMESPACE_BEGIN bool EqualsIgnoreCase(absl::string_view piece1, absl::string_view piece2) noexcept
Definition: abseil-cpp/absl/strings/match.cc:22
absl::StrContains
ABSL_NAMESPACE_BEGIN bool StrContains(absl::string_view haystack, absl::string_view needle) noexcept
Definition: third_party/abseil-cpp/absl/strings/match.h:46
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
d
static const fe d
Definition: curve25519_tables.h:19
absl::container_internal::internal_layout::Contains
absl::disjunction< std::is_same< T, Ts >... > Contains
Definition: abseil-cpp/absl/container/internal/layout.h:253
absl::debugging_internal::EndsWith
static bool EndsWith(State *state, const char chr)
Definition: abseil-cpp/absl/debugging/internal/demangle.cc:415
absl::EndsWithIgnoreCase
bool EndsWithIgnoreCase(absl::string_view text, absl::string_view suffix) noexcept
Definition: abseil-cpp/absl/strings/match.cc:36
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1967
absl::EndsWith
bool EndsWith(absl::string_view text, absl::string_view suffix) noexcept
Definition: third_party/abseil-cpp/absl/strings/match.h:68


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:22