Export of internal Abseil changes
-- ea0cfebeb69b25bec343652bbe1a203f5476c51a by Mark Barolak <mbar@google.com>: Change "std::string" to "string" in places where a "std::" qualification was incorrectly inserted by automation. PiperOrigin-RevId: 300108520 GitOrigin-RevId: ea0cfebeb69b25bec343652bbe1a203f5476c51a Change-Id: Ie3621e63a6ebad67b9fe56a3ebe33e1d50dac602
This commit is contained in:
parent
d936052d32
commit
a877af1f29
68 changed files with 191 additions and 191 deletions
|
|
@ -619,10 +619,10 @@ from_chars_result FromCharsImpl(const char* first, const char* last,
|
|||
// Either we failed to parse a hex float after the "0x", or we read
|
||||
// "0xinf" or "0xnan" which we don't want to match.
|
||||
//
|
||||
// However, a std::string that begins with "0x" also begins with "0", which
|
||||
// However, a string that begins with "0x" also begins with "0", which
|
||||
// is normally a valid match for the number zero. So we want these
|
||||
// strings to match zero unless fmt_flags is `scientific`. (This flag
|
||||
// means an exponent is required, which the std::string "0" does not have.)
|
||||
// means an exponent is required, which the string "0" does not have.)
|
||||
if (fmt_flags == chars_format::scientific) {
|
||||
result.ec = std::errc::invalid_argument;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ BENCHMARK(BM_Absl_HugeMantissa);
|
|||
std::string MakeHardCase(int length) {
|
||||
// The number 1.1521...e-297 is exactly halfway between 12345 * 2**-1000 and
|
||||
// the next larger representable number. The digits of this number are in
|
||||
// the std::string below.
|
||||
// the string below.
|
||||
const std::string digits =
|
||||
"1."
|
||||
"152113937042223790993097181572444900347587985074226836242307364987727724"
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ class Cord {
|
|||
|
||||
// Copies the contents from `src` to `*dst`.
|
||||
//
|
||||
// This function optimizes the case of reusing the destination std::string since it
|
||||
// This function optimizes the case of reusing the destination string since it
|
||||
// can reuse previously allocated capacity. However, this function does not
|
||||
// guarantee that pointers previously returned by `dst->data()` remain valid
|
||||
// even if `*dst` had enough capacity to hold `src`. If `*dst` is a new
|
||||
|
|
@ -603,7 +603,7 @@ class Cord {
|
|||
}
|
||||
void CopyTo(std::string* dst) const {
|
||||
// memcpy is much faster when operating on a known size. On most supported
|
||||
// platforms, the small std::string optimization is large enough that resizing
|
||||
// platforms, the small string optimization is large enough that resizing
|
||||
// to 15 bytes does not cause a memory allocation.
|
||||
absl::strings_internal::STLStringResizeUninitialized(dst,
|
||||
sizeof(data_) - 1);
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ TEST(Cord, AllFlatSizes) {
|
|||
using absl::strings_internal::CordTestAccess;
|
||||
|
||||
for (size_t s = 0; s < CordTestAccess::MaxFlatLength(); s++) {
|
||||
// Make a std::string of length s.
|
||||
// Make a string of length s.
|
||||
std::string src;
|
||||
while (src.size() < s) {
|
||||
src.push_back('a' + (src.size() % 26));
|
||||
|
|
@ -409,7 +409,7 @@ static void VerifyCopyToString(const absl::Cord& cord) {
|
|||
|
||||
if (cord.size() <= kInitialLength) {
|
||||
EXPECT_EQ(has_initial_contents.data(), address_before_copy)
|
||||
<< "CopyCordToString allocated new std::string storage; "
|
||||
<< "CopyCordToString allocated new string storage; "
|
||||
"has_initial_contents = \""
|
||||
<< has_initial_contents << "\"";
|
||||
}
|
||||
|
|
@ -856,7 +856,7 @@ TEST(Cord, CompareAfterAssign) {
|
|||
}
|
||||
|
||||
// Test CompareTo() and ComparePrefix() against string and substring
|
||||
// comparison methods from std::basic_string.
|
||||
// comparison methods from basic_string.
|
||||
static void TestCompare(const absl::Cord& c, const absl::Cord& d,
|
||||
RandomEngine* rng) {
|
||||
typedef std::basic_string<uint8_t> ustring;
|
||||
|
|
@ -912,7 +912,7 @@ void CompareOperators() {
|
|||
|
||||
EXPECT_TRUE(a == a);
|
||||
// For pointer type (i.e. `const char*`), operator== compares the address
|
||||
// instead of the std::string, so `a == const char*("a")` isn't necessarily true.
|
||||
// instead of the string, so `a == const char*("a")` isn't necessarily true.
|
||||
EXPECT_TRUE(std::is_pointer<T1>::value || a == T1("a"));
|
||||
EXPECT_TRUE(std::is_pointer<T2>::value || a == T2("a"));
|
||||
EXPECT_FALSE(a == b);
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ bool Base64UnescapeInternal(const char* src_param, size_t szsrc, char* dest,
|
|||
|
||||
// The GET_INPUT macro gets the next input character, skipping
|
||||
// over any whitespace, and stopping when we reach the end of the
|
||||
// std::string or when we read any non-data character. The arguments are
|
||||
// string or when we read any non-data character. The arguments are
|
||||
// an arbitrary identifier (used as a label for goto) and the number
|
||||
// of data bytes that must remain in the input to avoid aborting the
|
||||
// loop.
|
||||
|
|
@ -473,18 +473,18 @@ bool Base64UnescapeInternal(const char* src_param, size_t szsrc, char* dest,
|
|||
if (dest) {
|
||||
// This loop consumes 4 input bytes and produces 3 output bytes
|
||||
// per iteration. We can't know at the start that there is enough
|
||||
// data left in the std::string for a full iteration, so the loop may
|
||||
// data left in the string for a full iteration, so the loop may
|
||||
// break out in the middle; if so 'state' will be set to the
|
||||
// number of input bytes read.
|
||||
|
||||
while (szsrc >= 4) {
|
||||
// We'll start by optimistically assuming that the next four
|
||||
// bytes of the std::string (src[0..3]) are four good data bytes
|
||||
// bytes of the string (src[0..3]) are four good data bytes
|
||||
// (that is, no nulls, whitespace, padding chars, or illegal
|
||||
// chars). We need to test src[0..2] for nulls individually
|
||||
// before constructing temp to preserve the property that we
|
||||
// never read past a null in the std::string (no matter how long
|
||||
// szsrc claims the std::string is).
|
||||
// never read past a null in the string (no matter how long
|
||||
// szsrc claims the string is).
|
||||
|
||||
if (!src[0] || !src[1] || !src[2] ||
|
||||
((temp = ((unsigned(unbase64[src[0]]) << 18) |
|
||||
|
|
@ -509,7 +509,7 @@ bool Base64UnescapeInternal(const char* src_param, size_t szsrc, char* dest,
|
|||
temp = (temp << 6) | decode;
|
||||
} else {
|
||||
// We really did have four good data bytes, so advance four
|
||||
// characters in the std::string.
|
||||
// characters in the string.
|
||||
|
||||
szsrc -= 4;
|
||||
src += 4;
|
||||
|
|
@ -644,7 +644,7 @@ bool Base64UnescapeInternal(const char* src_param, size_t szsrc, char* dest,
|
|||
state);
|
||||
}
|
||||
|
||||
// The remainder of the std::string should be all whitespace, mixed with
|
||||
// The remainder of the string should be all whitespace, mixed with
|
||||
// exactly 0 equals signs, or exactly 'expected_equals' equals
|
||||
// signs. (Always accepting 0 equals signs is an Abseil extension
|
||||
// not covered in the RFC, as is accepting dot as the pad character.)
|
||||
|
|
@ -771,7 +771,7 @@ constexpr char kWebSafeBase64Chars[] =
|
|||
template <typename String>
|
||||
bool Base64UnescapeInternal(const char* src, size_t slen, String* dest,
|
||||
const signed char* unbase64) {
|
||||
// Determine the size of the output std::string. Base64 encodes every 3 bytes into
|
||||
// Determine the size of the output string. Base64 encodes every 3 bytes into
|
||||
// 4 characters. any leftover chars are added directly for good measure.
|
||||
// This is documented in the base64 RFC: http://tools.ietf.org/html/rfc3548
|
||||
const size_t dest_len = 3 * (slen / 4) + (slen % 4);
|
||||
|
|
@ -779,7 +779,7 @@ bool Base64UnescapeInternal(const char* src, size_t slen, String* dest,
|
|||
strings_internal::STLStringResizeUninitialized(dest, dest_len);
|
||||
|
||||
// We are getting the destination buffer by getting the beginning of the
|
||||
// std::string and converting it into a char *.
|
||||
// string and converting it into a char *.
|
||||
size_t len;
|
||||
const bool ok =
|
||||
Base64UnescapeInternal(src, slen, &(*dest)[0], dest_len, unbase64, &len);
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ static struct {
|
|||
absl::string_view plaintext;
|
||||
absl::string_view cyphertext;
|
||||
} const base64_tests[] = {
|
||||
// Empty std::string.
|
||||
// Empty string.
|
||||
{{"", 0}, {"", 0}},
|
||||
{{nullptr, 0},
|
||||
{"", 0}}, // if length is zero, plaintext ptr must be ignored!
|
||||
|
|
@ -586,7 +586,7 @@ void TestEscapeAndUnescape() {
|
|||
EXPECT_EQ(encoded, websafe);
|
||||
EXPECT_EQ(absl::WebSafeBase64Escape(tc.plaintext), websafe);
|
||||
|
||||
// Let's try the std::string version of the decoder
|
||||
// Let's try the string version of the decoder
|
||||
decoded = "this junk should be ignored";
|
||||
EXPECT_TRUE(absl::WebSafeBase64Unescape(websafe, &decoded));
|
||||
EXPECT_EQ(decoded, tc.plaintext);
|
||||
|
|
@ -625,7 +625,7 @@ TEST(Base64, DISABLED_HugeData) {
|
|||
std::string escaped;
|
||||
absl::Base64Escape(huge, &escaped);
|
||||
|
||||
// Generates the std::string that should match a base64 encoded "xxx..." std::string.
|
||||
// Generates the string that should match a base64 encoded "xxx..." string.
|
||||
// "xxx" in base64 is "eHh4".
|
||||
std::string expected_encoding;
|
||||
expected_encoding.reserve(kSize / 3 * 4);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class Charmap {
|
|||
CharMaskForWord(x, 2), CharMaskForWord(x, 3));
|
||||
}
|
||||
|
||||
// Containing all the chars in the C-std::string 's'.
|
||||
// Containing all the chars in the C-string 's'.
|
||||
// Note that this is expensively recursive because of the C++11 constexpr
|
||||
// formulation. Use only in constexpr initializers.
|
||||
static constexpr Charmap FromString(const char* s) {
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ int BigUnsigned<max_words>::ReadDigits(const char* begin, const char* end,
|
|||
++dropped_digits;
|
||||
}
|
||||
if (begin < end && *std::prev(end) == '.') {
|
||||
// If the std::string ends in '.', either before or after dropping zeroes, then
|
||||
// If the string ends in '.', either before or after dropping zeroes, then
|
||||
// drop the decimal point and look for more digits to drop.
|
||||
dropped_digits = 0;
|
||||
--end;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class BigUnsigned {
|
|||
static_cast<uint32_t>(v >> 32)} {}
|
||||
|
||||
// Constructs a BigUnsigned from the given string_view containing a decimal
|
||||
// value. If the input std::string is not a decimal integer, constructs a 0
|
||||
// value. If the input string is not a decimal integer, constructs a 0
|
||||
// instead.
|
||||
explicit BigUnsigned(absl::string_view sv) : size_(0), words_{} {
|
||||
// Check for valid input, returning a 0 otherwise. This is reasonable
|
||||
|
|
@ -210,7 +210,7 @@ class BigUnsigned {
|
|||
return words_[index];
|
||||
}
|
||||
|
||||
// Returns this integer as a decimal std::string. This is not used in the decimal-
|
||||
// Returns this integer as a decimal string. This is not used in the decimal-
|
||||
// to-binary conversion; it is intended to aid in testing.
|
||||
std::string ToString() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ bool ParseInfinityOrNan(const char* begin, const char* end,
|
|||
switch (*begin) {
|
||||
case 'i':
|
||||
case 'I': {
|
||||
// An infinity std::string consists of the characters "inf" or "infinity",
|
||||
// An infinity string consists of the characters "inf" or "infinity",
|
||||
// case insensitive.
|
||||
if (strings_internal::memcasecmp(begin + 1, "nf", 2) != 0) {
|
||||
return false;
|
||||
|
|
@ -326,7 +326,7 @@ bool ParseInfinityOrNan(const char* begin, const char* end,
|
|||
}
|
||||
out->type = strings_internal::FloatType::kNan;
|
||||
out->end = begin + 3;
|
||||
// NaN is allowed to be followed by a parenthesized std::string, consisting of
|
||||
// NaN is allowed to be followed by a parenthesized string, consisting of
|
||||
// only the characters [a-zA-Z0-9_]. Match that if it's present.
|
||||
begin += 3;
|
||||
if (begin < end && *begin == '(') {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ void ExpectParsedFloat(std::string s, absl::chars_format format_flags,
|
|||
}
|
||||
const std::string::size_type expected_characters_matched = s.find('$');
|
||||
ABSL_RAW_CHECK(expected_characters_matched != std::string::npos,
|
||||
"Input std::string must contain $");
|
||||
"Input string must contain $");
|
||||
s.replace(expected_characters_matched, 1, "");
|
||||
|
||||
ParsedFloat parsed =
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ inline const std::array<uint64_test_case, 34>& strtouint64_test_cases() {
|
|||
|
||||
{"0x1234", true, 16, 0x1234},
|
||||
|
||||
// Base-10 std::string version.
|
||||
// Base-10 string version.
|
||||
{"1234", true, 0, 1234},
|
||||
{nullptr, false, 0, 0},
|
||||
}};
|
||||
|
|
|
|||
|
|
@ -76,11 +76,11 @@ class FormatSpecTemplate
|
|||
public:
|
||||
#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER
|
||||
|
||||
// Honeypot overload for when the std::string is not constexpr.
|
||||
// Honeypot overload for when the string is not constexpr.
|
||||
// We use the 'unavailable' attribute to give a better compiler error than
|
||||
// just 'method is deleted'.
|
||||
FormatSpecTemplate(...) // NOLINT
|
||||
__attribute__((unavailable("Format std::string is not constexpr.")));
|
||||
__attribute__((unavailable("Format string is not constexpr.")));
|
||||
|
||||
// Honeypot overload for when the format is constexpr and invalid.
|
||||
// We use the 'unavailable' attribute to give a better compiler error than
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ bool ParseFormatString(string_view src, Consumer consumer) {
|
|||
auto tag = GetTagForChar(percent[1]);
|
||||
if (tag.is_conv()) {
|
||||
if (ABSL_PREDICT_FALSE(next_arg < 0)) {
|
||||
// This indicates an error in the format std::string.
|
||||
// This indicates an error in the format string.
|
||||
// The only way to get `next_arg < 0` here is to have a positional
|
||||
// argument first which sets next_arg to -1 and then a non-positional
|
||||
// argument.
|
||||
|
|
@ -287,7 +287,7 @@ class ExtendedParsedFormat : public str_format_internal::ParsedFormatBase {
|
|||
#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER
|
||||
__attribute__((
|
||||
enable_if(str_format_internal::EnsureConstexpr(format),
|
||||
"Format std::string is not constexpr."),
|
||||
"Format string is not constexpr."),
|
||||
enable_if(str_format_internal::ValidFormatImpl<C...>(format),
|
||||
"Format specified does not match the template arguments.")))
|
||||
#endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ TEST(stringtest, safe_strto32_base) {
|
|||
EXPECT_TRUE(safe_strto32_base(std::string("0x1234"), &value, 16));
|
||||
EXPECT_EQ(0x1234, value);
|
||||
|
||||
// Base-10 std::string version.
|
||||
// Base-10 string version.
|
||||
EXPECT_TRUE(safe_strto32_base("1234", &value, 10));
|
||||
EXPECT_EQ(1234, value);
|
||||
}
|
||||
|
|
@ -622,7 +622,7 @@ TEST(stringtest, safe_strto64_base) {
|
|||
EXPECT_TRUE(safe_strto64_base(std::string("0x1234"), &value, 16));
|
||||
EXPECT_EQ(0x1234, value);
|
||||
|
||||
// Base-10 std::string version.
|
||||
// Base-10 string version.
|
||||
EXPECT_TRUE(safe_strto64_base("1234", &value, 10));
|
||||
EXPECT_EQ(1234, value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ class AlphaNum {
|
|||
const std::basic_string<char, std::char_traits<char>, Allocator>& str)
|
||||
: piece_(str) {}
|
||||
|
||||
// Use std::string literals ":" instead of character literals ':'.
|
||||
// Use string literals ":" instead of character literals ':'.
|
||||
AlphaNum(char c) = delete; // NOLINT(runtime/explicit)
|
||||
|
||||
AlphaNum(const AlphaNum&) = delete;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
namespace {
|
||||
|
||||
const char kStringOne[] = "Once Upon A Time, ";
|
||||
const char kStringTwo[] = "There was a std::string benchmark";
|
||||
const char kStringTwo[] = "There was a string benchmark";
|
||||
|
||||
// We want to include negative numbers in the benchmark, so this function
|
||||
// is used to count 0, 1, -1, 2, -2, 3, -3, ...
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ TEST(StrCat, Basics) {
|
|||
EXPECT_EQ(result, "12345678910, 10987654321!");
|
||||
|
||||
std::string one =
|
||||
"1"; // Actually, it's the size of this std::string that we want; a
|
||||
"1"; // Actually, it's the size of this string that we want; a
|
||||
// 64-bit build distinguishes between size_t and uint64_t,
|
||||
// even though they're both unsigned 64-bit values.
|
||||
result = absl::StrCat("And a ", one.size(), " and a ",
|
||||
|
|
@ -375,7 +375,7 @@ TEST(StrAppend, Basics) {
|
|||
EXPECT_EQ(result.substr(old_size), "12345678910, 10987654321!");
|
||||
|
||||
std::string one =
|
||||
"1"; // Actually, it's the size of this std::string that we want; a
|
||||
"1"; // Actually, it's the size of this string that we want; a
|
||||
// 64-bit build distinguishes between size_t and uint64_t,
|
||||
// even though they're both unsigned 64-bit values.
|
||||
old_size = result.size();
|
||||
|
|
@ -463,7 +463,7 @@ TEST(StrAppend, CornerCases) {
|
|||
}
|
||||
|
||||
TEST(StrAppend, CornerCasesNonEmptyAppend) {
|
||||
for (std::string result : {"hello", "a std::string too long to fit in the SSO"}) {
|
||||
for (std::string result : {"hello", "a string too long to fit in the SSO"}) {
|
||||
const std::string expected = result;
|
||||
absl::StrAppend(&result, "");
|
||||
EXPECT_EQ(result, expected);
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ class TempFile {
|
|||
|
||||
std::FILE* file() const { return file_; }
|
||||
|
||||
// Read the file into a std::string.
|
||||
// Read the file into a string.
|
||||
std::string ReadFile() {
|
||||
std::fseek(file_, 0, SEEK_END);
|
||||
int size = std::ftell(file_);
|
||||
|
|
@ -345,7 +345,7 @@ TEST(StrFormat, BehavesAsDocumented) {
|
|||
EXPECT_EQ(StrFormat("%c", int{'a'}), "a");
|
||||
EXPECT_EQ(StrFormat("%c", long{'a'}), "a"); // NOLINT
|
||||
EXPECT_EQ(StrFormat("%c", uint64_t{'a'}), "a");
|
||||
// "s" - std::string Eg: "C" -> "C", std::string("C++") -> "C++"
|
||||
// "s" - string Eg: "C" -> "C", std::string("C++") -> "C++"
|
||||
// Formats std::string, char*, string_view, and Cord.
|
||||
EXPECT_EQ(StrFormat("%s", "C"), "C");
|
||||
EXPECT_EQ(StrFormat("%s", std::string("C++")), "C++");
|
||||
|
|
|
|||
|
|
@ -134,26 +134,26 @@ TEST(StrJoin, APIExamples) {
|
|||
//
|
||||
|
||||
{
|
||||
// Empty range yields an empty std::string.
|
||||
// Empty range yields an empty string.
|
||||
std::vector<std::string> v;
|
||||
EXPECT_EQ("", absl::StrJoin(v, "-"));
|
||||
}
|
||||
|
||||
{
|
||||
// A range of 1 element gives a std::string with that element but no
|
||||
// A range of 1 element gives a string with that element but no
|
||||
// separator.
|
||||
std::vector<std::string> v = {"foo"};
|
||||
EXPECT_EQ("foo", absl::StrJoin(v, "-"));
|
||||
}
|
||||
|
||||
{
|
||||
// A range with a single empty std::string element
|
||||
// A range with a single empty string element
|
||||
std::vector<std::string> v = {""};
|
||||
EXPECT_EQ("", absl::StrJoin(v, "-"));
|
||||
}
|
||||
|
||||
{
|
||||
// A range with 2 elements, one of which is an empty std::string
|
||||
// A range with 2 elements, one of which is an empty string
|
||||
std::vector<std::string> v = {"a", ""};
|
||||
EXPECT_EQ("a-", absl::StrJoin(v, "-"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ void SetUpStrings() {
|
|||
}
|
||||
}
|
||||
// big_string->resize(50);
|
||||
// OK, we've set up the std::string, now let's set up expectations - first by
|
||||
// OK, we've set up the string, now let's set up expectations - first by
|
||||
// just replacing "the" with "box"
|
||||
after_replacing_the = new std::string(*big_string);
|
||||
for (size_t pos = 0;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
TEST(StrReplaceAll, OneReplacement) {
|
||||
std::string s;
|
||||
|
||||
// Empty std::string.
|
||||
// Empty string.
|
||||
s = absl::StrReplaceAll(s, {{"", ""}});
|
||||
EXPECT_EQ(s, "");
|
||||
s = absl::StrReplaceAll(s, {{"x", ""}});
|
||||
|
|
@ -47,7 +47,7 @@ TEST(StrReplaceAll, OneReplacement) {
|
|||
s = absl::StrReplaceAll("abc", {{"xyz", "123"}});
|
||||
EXPECT_EQ(s, "abc");
|
||||
|
||||
// Replace entire std::string.
|
||||
// Replace entire string.
|
||||
s = absl::StrReplaceAll("abc", {{"abc", "xyz"}});
|
||||
EXPECT_EQ(s, "xyz");
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ TEST(StrReplaceAll, OneReplacement) {
|
|||
TEST(StrReplaceAll, ManyReplacements) {
|
||||
std::string s;
|
||||
|
||||
// Empty std::string.
|
||||
// Empty string.
|
||||
s = absl::StrReplaceAll("", {{"", ""}, {"x", ""}, {"", "y"}, {"x", "y"}});
|
||||
EXPECT_EQ(s, "");
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ TEST(StrReplaceAll, ManyReplacements) {
|
|||
s = absl::StrReplaceAll("abc", {{"", ""}, {"", "y"}, {"x", ""}});
|
||||
EXPECT_EQ(s, "abc");
|
||||
|
||||
// Replace entire std::string, one char at a time
|
||||
// Replace entire string, one char at a time
|
||||
s = absl::StrReplaceAll("abc", {{"a", "x"}, {"b", "y"}, {"c", "z"}});
|
||||
EXPECT_EQ(s, "xyz");
|
||||
s = absl::StrReplaceAll("zxy", {{"z", "x"}, {"x", "y"}, {"y", "z"}});
|
||||
|
|
@ -264,7 +264,7 @@ TEST(StrReplaceAll, Inplace) {
|
|||
std::string s;
|
||||
int reps;
|
||||
|
||||
// Empty std::string.
|
||||
// Empty string.
|
||||
s = "";
|
||||
reps = absl::StrReplaceAll({{"", ""}, {"x", ""}, {"", "y"}, {"x", "y"}}, &s);
|
||||
EXPECT_EQ(reps, 0);
|
||||
|
|
@ -276,7 +276,7 @@ TEST(StrReplaceAll, Inplace) {
|
|||
EXPECT_EQ(reps, 0);
|
||||
EXPECT_EQ(s, "abc");
|
||||
|
||||
// Replace entire std::string, one char at a time
|
||||
// Replace entire string, one char at a time
|
||||
s = "abc";
|
||||
reps = absl::StrReplaceAll({{"a", "x"}, {"b", "y"}, {"c", "z"}}, &s);
|
||||
EXPECT_EQ(reps, 3);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ absl::string_view GenericFind(absl::string_view text,
|
|||
absl::string_view delimiter, size_t pos,
|
||||
FindPolicy find_policy) {
|
||||
if (delimiter.empty() && text.length() > 0) {
|
||||
// Special case for empty std::string delimiters: always return a zero-length
|
||||
// Special case for empty string delimiters: always return a zero-length
|
||||
// absl::string_view referring to the item at position 1 past pos.
|
||||
return absl::string_view(text.data() + pos + 1, 0);
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ absl::string_view ByLength::Find(absl::string_view text,
|
|||
size_t pos) const {
|
||||
pos = std::min(pos, text.size()); // truncate `pos`
|
||||
absl::string_view substr = text.substr(pos);
|
||||
// If the std::string is shorter than the chunk size we say we
|
||||
// If the string is shorter than the chunk size we say we
|
||||
// "can't find the delimiter" so this will be the last chunk.
|
||||
if (substr.length() <= static_cast<size_t>(length_))
|
||||
return absl::string_view(text.data() + text.size(), 0);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ TEST(Split, TraitsTest) {
|
|||
// namespaces just like callers will need to use.
|
||||
TEST(Split, APIExamples) {
|
||||
{
|
||||
// Passes std::string delimiter. Assumes the default of ByString.
|
||||
// Passes string delimiter. Assumes the default of ByString.
|
||||
std::vector<std::string> v = absl::StrSplit("a,b,c", ","); // NOLINT
|
||||
EXPECT_THAT(v, ElementsAre("a", "b", "c"));
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ TEST(Split, APIExamples) {
|
|||
}
|
||||
|
||||
{
|
||||
// Uses the Literal std::string "=>" as the delimiter.
|
||||
// Uses the Literal string "=>" as the delimiter.
|
||||
const std::vector<std::string> v = absl::StrSplit("a=>b=>c", "=>");
|
||||
EXPECT_THAT(v, ElementsAre("a", "b", "c"));
|
||||
}
|
||||
|
|
@ -121,17 +121,17 @@ TEST(Split, APIExamples) {
|
|||
}
|
||||
|
||||
{
|
||||
// Splits the input std::string into individual characters by using an empty
|
||||
// std::string as the delimiter.
|
||||
// Splits the input string into individual characters by using an empty
|
||||
// string as the delimiter.
|
||||
std::vector<std::string> v = absl::StrSplit("abc", "");
|
||||
EXPECT_THAT(v, ElementsAre("a", "b", "c"));
|
||||
}
|
||||
|
||||
{
|
||||
// Splits std::string data with embedded NUL characters, using NUL as the
|
||||
// Splits string data with embedded NUL characters, using NUL as the
|
||||
// delimiter. A simple delimiter of "\0" doesn't work because strlen() will
|
||||
// say that's the empty std::string when constructing the absl::string_view
|
||||
// delimiter. Instead, a non-empty std::string containing NUL can be used as the
|
||||
// say that's the empty string when constructing the absl::string_view
|
||||
// delimiter. Instead, a non-empty string containing NUL can be used as the
|
||||
// delimiter.
|
||||
std::string embedded_nulls("a\0b\0c", 5);
|
||||
std::string null_delim("\0", 1);
|
||||
|
|
@ -436,7 +436,7 @@ TEST(Splitter, ConversionOperator) {
|
|||
// less-than, equal-to, and more-than 2 strings.
|
||||
TEST(Splitter, ToPair) {
|
||||
{
|
||||
// Empty std::string
|
||||
// Empty string
|
||||
std::pair<std::string, std::string> p = absl::StrSplit("", ',');
|
||||
EXPECT_EQ("", p.first);
|
||||
EXPECT_EQ("", p.second);
|
||||
|
|
@ -565,7 +565,7 @@ TEST(Split, AcceptsCertainTemporaries) {
|
|||
|
||||
TEST(Split, Temporary) {
|
||||
// Use a std::string longer than the SSO length, so that when the temporary is
|
||||
// destroyed, if the splitter keeps a reference to the std::string's contents,
|
||||
// destroyed, if the splitter keeps a reference to the string's contents,
|
||||
// it'll reference freed memory instead of just dead on-stack memory.
|
||||
const char input[] = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u";
|
||||
EXPECT_LT(sizeof(std::string), ABSL_ARRAYSIZE(input))
|
||||
|
|
@ -651,14 +651,14 @@ TEST(Split, UTF8) {
|
|||
// Tests splitting utf8 strings and utf8 delimiters.
|
||||
std::string utf8_string = u8"\u03BA\u1F79\u03C3\u03BC\u03B5";
|
||||
{
|
||||
// A utf8 input std::string with an ascii delimiter.
|
||||
// A utf8 input string with an ascii delimiter.
|
||||
std::string to_split = "a," + utf8_string;
|
||||
std::vector<absl::string_view> v = absl::StrSplit(to_split, ',');
|
||||
EXPECT_THAT(v, ElementsAre("a", utf8_string));
|
||||
}
|
||||
|
||||
{
|
||||
// A utf8 input std::string and a utf8 delimiter.
|
||||
// A utf8 input string and a utf8 delimiter.
|
||||
std::string to_split = "a," + utf8_string + ",b";
|
||||
std::string unicode_delimiter = "," + utf8_string + ",";
|
||||
std::vector<absl::string_view> v =
|
||||
|
|
@ -667,7 +667,7 @@ TEST(Split, UTF8) {
|
|||
}
|
||||
|
||||
{
|
||||
// A utf8 input std::string and ByAnyChar with ascii chars.
|
||||
// A utf8 input string and ByAnyChar with ascii chars.
|
||||
std::vector<absl::string_view> v =
|
||||
absl::StrSplit(u8"Foo h\u00E4llo th\u4E1Ere", absl::ByAnyChar(" \t"));
|
||||
EXPECT_THAT(v, ElementsAre("Foo", u8"h\u00E4llo", u8"th\u4E1Ere"));
|
||||
|
|
@ -814,10 +814,10 @@ TEST(Delimiter, ByString) {
|
|||
ByString comma_string(",");
|
||||
TestComma(comma_string);
|
||||
|
||||
// The first occurrence of empty std::string ("") in a std::string is at position 0.
|
||||
// The first occurrence of empty string ("") in a string is at position 0.
|
||||
// There is a test below that demonstrates this for absl::string_view::find().
|
||||
// If the ByString delimiter returned position 0 for this, there would
|
||||
// be an infinite loop in the SplitIterator code. To avoid this, empty std::string
|
||||
// be an infinite loop in the SplitIterator code. To avoid this, empty string
|
||||
// is a special case in that it always returns the item at position 1.
|
||||
absl::string_view abc("abc");
|
||||
EXPECT_EQ(0, abc.find("")); // "" is found at position 0
|
||||
|
|
@ -876,7 +876,7 @@ TEST(Delimiter, ByAnyChar) {
|
|||
EXPECT_FALSE(IsFoundAt("=", two_delims, -1));
|
||||
|
||||
// ByAnyChar behaves just like ByString when given a delimiter of empty
|
||||
// std::string. That is, it always returns a zero-length absl::string_view
|
||||
// string. That is, it always returns a zero-length absl::string_view
|
||||
// referring to the item at position 1, not position 0.
|
||||
ByAnyChar empty("");
|
||||
EXPECT_FALSE(IsFoundAt("", empty, 0));
|
||||
|
|
@ -913,7 +913,7 @@ TEST(Split, WorksWithLargeStrings) {
|
|||
std::vector<absl::string_view> v = absl::StrSplit(s, '-');
|
||||
EXPECT_EQ(2, v.size());
|
||||
// The first element will contain 2G of 'x's.
|
||||
// testing::StartsWith is too slow with a 2G std::string.
|
||||
// testing::StartsWith is too slow with a 2G string.
|
||||
EXPECT_EQ('x', v[0][0]);
|
||||
EXPECT_EQ('x', v[0][1]);
|
||||
EXPECT_EQ('x', v[0][3]);
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ class string_view {
|
|||
// stored elsewhere). Note that `string_view::data()` may contain embedded nul
|
||||
// characters, but the returned buffer may or may not be NUL-terminated;
|
||||
// therefore, do not pass `data()` to a routine that expects a NUL-terminated
|
||||
// std::string.
|
||||
// string.
|
||||
constexpr const_pointer data() const noexcept { return ptr_; }
|
||||
|
||||
// Modifiers
|
||||
|
|
@ -327,7 +327,7 @@ class string_view {
|
|||
// string_view::remove_prefix()
|
||||
//
|
||||
// Removes the first `n` characters from the `string_view`. Note that the
|
||||
// underlying std::string is not changed, only the view.
|
||||
// underlying string is not changed, only the view.
|
||||
void remove_prefix(size_type n) {
|
||||
assert(n <= length_);
|
||||
ptr_ += n;
|
||||
|
|
@ -337,7 +337,7 @@ class string_view {
|
|||
// string_view::remove_suffix()
|
||||
//
|
||||
// Removes the last `n` characters from the `string_view`. Note that the
|
||||
// underlying std::string is not changed, only the view.
|
||||
// underlying string is not changed, only the view.
|
||||
void remove_suffix(size_type n) {
|
||||
assert(n <= length_);
|
||||
length_ -= n;
|
||||
|
|
@ -394,7 +394,7 @@ class string_view {
|
|||
//
|
||||
// Performs a lexicographical comparison between the `string_view` and
|
||||
// another `absl::string_view`, returning -1 if `this` is less than, 0 if
|
||||
// `this` is equal to, and 1 if `this` is greater than the passed std::string
|
||||
// `this` is equal to, and 1 if `this` is greater than the passed string
|
||||
// view. Note that in the case of data equality, a further comparison is made
|
||||
// on the respective sizes of the two `string_view`s to determine which is
|
||||
// smaller, equal, or greater.
|
||||
|
|
@ -420,17 +420,17 @@ class string_view {
|
|||
}
|
||||
|
||||
// Overload of `string_view::compare()` for comparing a `string_view` and a
|
||||
// a different C-style std::string `s`.
|
||||
// a different C-style string `s`.
|
||||
int compare(const char* s) const { return compare(string_view(s)); }
|
||||
|
||||
// Overload of `string_view::compare()` for comparing a substring of the
|
||||
// `string_view` and a different std::string C-style std::string `s`.
|
||||
// `string_view` and a different string C-style string `s`.
|
||||
int compare(size_type pos1, size_type count1, const char* s) const {
|
||||
return substr(pos1, count1).compare(string_view(s));
|
||||
}
|
||||
|
||||
// Overload of `string_view::compare()` for comparing a substring of the
|
||||
// `string_view` and a substring of a different C-style std::string `s`.
|
||||
// `string_view` and a substring of a different C-style string `s`.
|
||||
int compare(size_type pos1, size_type count1, const char* s,
|
||||
size_type count2) const {
|
||||
return substr(pos1, count1).compare(string_view(s, count2));
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ TEST(StringViewTest, STL2) {
|
|||
EXPECT_EQ(a.find(e, 17), 17);
|
||||
absl::string_view g("xx not found bb");
|
||||
EXPECT_EQ(a.find(g), absl::string_view::npos);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(d.find(b), absl::string_view::npos);
|
||||
EXPECT_EQ(e.find(b), absl::string_view::npos);
|
||||
EXPECT_EQ(d.find(b, 4), absl::string_view::npos);
|
||||
|
|
@ -438,7 +438,7 @@ TEST(StringViewTest, STL2) {
|
|||
EXPECT_EQ(g.find('o', 4), 4);
|
||||
EXPECT_EQ(g.find('o', 5), 8);
|
||||
EXPECT_EQ(a.find('b', 5), absl::string_view::npos);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(d.find('\0'), absl::string_view::npos);
|
||||
EXPECT_EQ(e.find('\0'), absl::string_view::npos);
|
||||
EXPECT_EQ(d.find('\0', 4), absl::string_view::npos);
|
||||
|
|
@ -465,7 +465,7 @@ TEST(StringViewTest, STL2) {
|
|||
EXPECT_EQ(e.rfind(b), absl::string_view::npos);
|
||||
EXPECT_EQ(d.rfind(b, 4), absl::string_view::npos);
|
||||
EXPECT_EQ(e.rfind(b, 7), absl::string_view::npos);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(d.rfind(d, 4), std::string().rfind(std::string()));
|
||||
EXPECT_EQ(e.rfind(d, 7), std::string().rfind(std::string()));
|
||||
EXPECT_EQ(d.rfind(e, 4), std::string().rfind(std::string()));
|
||||
|
|
@ -484,7 +484,7 @@ TEST(StringViewTest, STL2) {
|
|||
EXPECT_EQ(f.rfind('\0', 12), 3);
|
||||
EXPECT_EQ(f.rfind('3'), 2);
|
||||
EXPECT_EQ(f.rfind('5'), 5);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(d.rfind('o'), absl::string_view::npos);
|
||||
EXPECT_EQ(e.rfind('o'), absl::string_view::npos);
|
||||
EXPECT_EQ(d.rfind('o', 4), absl::string_view::npos);
|
||||
|
|
@ -520,7 +520,7 @@ TEST(StringViewTest, STL2FindFirst) {
|
|||
EXPECT_EQ(g.find_first_of(c), 0);
|
||||
EXPECT_EQ(a.find_first_of(f), absl::string_view::npos);
|
||||
EXPECT_EQ(f.find_first_of(a), absl::string_view::npos);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(a.find_first_of(d), absl::string_view::npos);
|
||||
EXPECT_EQ(a.find_first_of(e), absl::string_view::npos);
|
||||
EXPECT_EQ(d.find_first_of(b), absl::string_view::npos);
|
||||
|
|
@ -538,7 +538,7 @@ TEST(StringViewTest, STL2FindFirst) {
|
|||
EXPECT_EQ(a.find_first_not_of(f), 0);
|
||||
EXPECT_EQ(a.find_first_not_of(d), 0);
|
||||
EXPECT_EQ(a.find_first_not_of(e), 0);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(a.find_first_not_of(d), 0);
|
||||
EXPECT_EQ(a.find_first_not_of(e), 0);
|
||||
EXPECT_EQ(a.find_first_not_of(d, 1), 1);
|
||||
|
|
@ -566,7 +566,7 @@ TEST(StringViewTest, STL2FindFirst) {
|
|||
EXPECT_EQ(f.find_first_not_of('\0'), 0);
|
||||
EXPECT_EQ(f.find_first_not_of('\0', 3), 4);
|
||||
EXPECT_EQ(f.find_first_not_of('\0', 2), 2);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(d.find_first_not_of('x'), absl::string_view::npos);
|
||||
EXPECT_EQ(e.find_first_not_of('x'), absl::string_view::npos);
|
||||
EXPECT_EQ(d.find_first_not_of('\0'), absl::string_view::npos);
|
||||
|
|
@ -606,7 +606,7 @@ TEST(StringViewTest, STL2FindLast) {
|
|||
EXPECT_EQ(f.find_last_of(i, 5), 5);
|
||||
EXPECT_EQ(f.find_last_of(i, 6), 6);
|
||||
EXPECT_EQ(f.find_last_of(a, 4), absl::string_view::npos);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(f.find_last_of(d), absl::string_view::npos);
|
||||
EXPECT_EQ(f.find_last_of(e), absl::string_view::npos);
|
||||
EXPECT_EQ(f.find_last_of(d, 4), absl::string_view::npos);
|
||||
|
|
@ -632,7 +632,7 @@ TEST(StringViewTest, STL2FindLast) {
|
|||
EXPECT_EQ(a.find_last_not_of(c, 24), 22);
|
||||
EXPECT_EQ(a.find_last_not_of(b, 3), 3);
|
||||
EXPECT_EQ(a.find_last_not_of(b, 2), absl::string_view::npos);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(f.find_last_not_of(d), f.size()-1);
|
||||
EXPECT_EQ(f.find_last_not_of(e), f.size()-1);
|
||||
EXPECT_EQ(f.find_last_not_of(d, 4), 4);
|
||||
|
|
@ -656,7 +656,7 @@ TEST(StringViewTest, STL2FindLast) {
|
|||
EXPECT_EQ(h.find_last_not_of('x', 2), 2);
|
||||
EXPECT_EQ(h.find_last_not_of('=', 2), absl::string_view::npos);
|
||||
EXPECT_EQ(b.find_last_not_of('b', 1), 0);
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(d.find_last_not_of('x'), absl::string_view::npos);
|
||||
EXPECT_EQ(e.find_last_not_of('x'), absl::string_view::npos);
|
||||
EXPECT_EQ(d.find_last_not_of('\0'), absl::string_view::npos);
|
||||
|
|
@ -678,7 +678,7 @@ TEST(StringViewTest, STL2Substr) {
|
|||
EXPECT_EQ(a.substr(23, 99), c);
|
||||
EXPECT_EQ(a.substr(0), a);
|
||||
EXPECT_EQ(a.substr(3, 2), "de");
|
||||
// empty std::string nonsense
|
||||
// empty string nonsense
|
||||
EXPECT_EQ(d.substr(0, 99), e);
|
||||
// use of npos
|
||||
EXPECT_EQ(a.substr(0, absl::string_view::npos), a);
|
||||
|
|
@ -859,7 +859,7 @@ TEST(StringViewTest, NULLInput) {
|
|||
EXPECT_EQ(s.size(), 0);
|
||||
|
||||
// .ToString() on a absl::string_view with nullptr should produce the empty
|
||||
// std::string.
|
||||
// string.
|
||||
EXPECT_EQ("", std::string(s));
|
||||
#endif // ABSL_HAVE_STRING_VIEW_FROM_NULLPTR
|
||||
}
|
||||
|
|
@ -977,7 +977,7 @@ TEST(StringViewTest, ConstexprCompiles) {
|
|||
|
||||
#if defined(ABSL_USES_STD_STRING_VIEW)
|
||||
// In libstdc++ (as of 7.2), `std::string_view::string_view(const char*)`
|
||||
// calls `std::char_traits<char>::length(const char*)` to get the std::string
|
||||
// calls `std::char_traits<char>::length(const char*)` to get the string
|
||||
// length, but it is not marked constexpr yet. See GCC bug:
|
||||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78156
|
||||
// Also, there is a LWG issue that adds constexpr to length() which was just
|
||||
|
|
@ -1180,7 +1180,7 @@ TEST(FindOneCharTest, EdgeCases) {
|
|||
TEST(HugeStringView, TwoPointTwoGB) {
|
||||
if (sizeof(size_t) <= 4 || RunningOnValgrind())
|
||||
return;
|
||||
// Try a huge std::string piece.
|
||||
// Try a huge string piece.
|
||||
const size_t size = size_t{2200} * 1000 * 1000;
|
||||
std::string s(size, 'a');
|
||||
absl::string_view sp(s);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void SubstituteAndAppendArray(std::string* output, absl::string_view format,
|
|||
if (i + 1 >= format.size()) {
|
||||
#ifndef NDEBUG
|
||||
ABSL_RAW_LOG(FATAL,
|
||||
"Invalid absl::Substitute() format std::string: \"%s\".",
|
||||
"Invalid absl::Substitute() format string: \"%s\".",
|
||||
absl::CEscape(format).c_str());
|
||||
#endif
|
||||
return;
|
||||
|
|
@ -46,8 +46,8 @@ void SubstituteAndAppendArray(std::string* output, absl::string_view format,
|
|||
#ifndef NDEBUG
|
||||
ABSL_RAW_LOG(
|
||||
FATAL,
|
||||
"Invalid absl::Substitute() format std::string: asked for \"$"
|
||||
"%d\", but only %d args were given. Full format std::string was: "
|
||||
"Invalid absl::Substitute() format string: asked for \"$"
|
||||
"%d\", but only %d args were given. Full format string was: "
|
||||
"\"%s\".",
|
||||
index, static_cast<int>(num_args), absl::CEscape(format).c_str());
|
||||
#endif
|
||||
|
|
@ -61,7 +61,7 @@ void SubstituteAndAppendArray(std::string* output, absl::string_view format,
|
|||
} else {
|
||||
#ifndef NDEBUG
|
||||
ABSL_RAW_LOG(FATAL,
|
||||
"Invalid absl::Substitute() format std::string: \"%s\".",
|
||||
"Invalid absl::Substitute() format string: \"%s\".",
|
||||
absl::CEscape(format).c_str());
|
||||
#endif
|
||||
return;
|
||||
|
|
@ -73,7 +73,7 @@ void SubstituteAndAppendArray(std::string* output, absl::string_view format,
|
|||
|
||||
if (size == 0) return;
|
||||
|
||||
// Build the std::string.
|
||||
// Build the string.
|
||||
size_t original_size = output->size();
|
||||
strings_internal::STLStringResizeUninitialized(output, original_size + size);
|
||||
char* target = &(*output)[original_size];
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ namespace substitute_internal {
|
|||
// This class has implicit constructors.
|
||||
class Arg {
|
||||
public:
|
||||
// Overloads for std::string-y things
|
||||
// Overloads for string-y things
|
||||
//
|
||||
// Explicitly overload `const char*` so the compiler doesn't cast to `bool`.
|
||||
Arg(const char* value) // NOLINT(runtime/explicit)
|
||||
|
|
@ -360,13 +360,13 @@ inline void SubstituteAndAppend(
|
|||
void SubstituteAndAppend(std::string* output, const char* format)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 0,
|
||||
"There were no substitution arguments "
|
||||
"but this format std::string has a $[0-9] in it");
|
||||
"but this format string has a $[0-9] in it");
|
||||
|
||||
void SubstituteAndAppend(std::string* output, const char* format,
|
||||
const substitute_internal::Arg& a0)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 1,
|
||||
"There was 1 substitution argument given, but "
|
||||
"this format std::string is either missing its $0, or "
|
||||
"this format string is either missing its $0, or "
|
||||
"contains one of $1-$9");
|
||||
|
||||
void SubstituteAndAppend(std::string* output, const char* format,
|
||||
|
|
@ -374,7 +374,7 @@ void SubstituteAndAppend(std::string* output, const char* format,
|
|||
const substitute_internal::Arg& a1)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 3,
|
||||
"There were 2 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0/$1, or "
|
||||
"this format string is either missing its $0/$1, or "
|
||||
"contains one of $2-$9");
|
||||
|
||||
void SubstituteAndAppend(std::string* output, const char* format,
|
||||
|
|
@ -383,7 +383,7 @@ void SubstituteAndAppend(std::string* output, const char* format,
|
|||
const substitute_internal::Arg& a2)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 7,
|
||||
"There were 3 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0/$1/$2, or "
|
||||
"this format string is either missing its $0/$1/$2, or "
|
||||
"contains one of $3-$9");
|
||||
|
||||
void SubstituteAndAppend(std::string* output, const char* format,
|
||||
|
|
@ -393,7 +393,7 @@ void SubstituteAndAppend(std::string* output, const char* format,
|
|||
const substitute_internal::Arg& a3)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 15,
|
||||
"There were 4 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$3, or "
|
||||
"this format string is either missing its $0-$3, or "
|
||||
"contains one of $4-$9");
|
||||
|
||||
void SubstituteAndAppend(std::string* output, const char* format,
|
||||
|
|
@ -404,7 +404,7 @@ void SubstituteAndAppend(std::string* output, const char* format,
|
|||
const substitute_internal::Arg& a4)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 31,
|
||||
"There were 5 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$4, or "
|
||||
"this format string is either missing its $0-$4, or "
|
||||
"contains one of $5-$9");
|
||||
|
||||
void SubstituteAndAppend(std::string* output, const char* format,
|
||||
|
|
@ -416,7 +416,7 @@ void SubstituteAndAppend(std::string* output, const char* format,
|
|||
const substitute_internal::Arg& a5)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 63,
|
||||
"There were 6 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$5, or "
|
||||
"this format string is either missing its $0-$5, or "
|
||||
"contains one of $6-$9");
|
||||
|
||||
void SubstituteAndAppend(
|
||||
|
|
@ -426,7 +426,7 @@ void SubstituteAndAppend(
|
|||
const substitute_internal::Arg& a5, const substitute_internal::Arg& a6)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 127,
|
||||
"There were 7 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$6, or "
|
||||
"this format string is either missing its $0-$6, or "
|
||||
"contains one of $7-$9");
|
||||
|
||||
void SubstituteAndAppend(
|
||||
|
|
@ -437,7 +437,7 @@ void SubstituteAndAppend(
|
|||
const substitute_internal::Arg& a7)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 255,
|
||||
"There were 8 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$7, or "
|
||||
"this format string is either missing its $0-$7, or "
|
||||
"contains one of $8-$9");
|
||||
|
||||
void SubstituteAndAppend(
|
||||
|
|
@ -449,7 +449,7 @@ void SubstituteAndAppend(
|
|||
ABSL_BAD_CALL_IF(
|
||||
substitute_internal::PlaceholderBitmask(format) != 511,
|
||||
"There were 9 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$8, or contains a $9");
|
||||
"this format string is either missing its $0-$8, or contains a $9");
|
||||
|
||||
void SubstituteAndAppend(
|
||||
std::string* output, const char* format, const substitute_internal::Arg& a0,
|
||||
|
|
@ -460,7 +460,7 @@ void SubstituteAndAppend(
|
|||
const substitute_internal::Arg& a9)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 1023,
|
||||
"There were 10 substitution arguments given, but this "
|
||||
"format std::string doesn't contain all of $0 through $9");
|
||||
"format string doesn't contain all of $0 through $9");
|
||||
#endif // ABSL_BAD_CALL_IF
|
||||
|
||||
// Substitute()
|
||||
|
|
@ -586,19 +586,19 @@ ABSL_MUST_USE_RESULT inline std::string Substitute(
|
|||
std::string Substitute(const char* format)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 0,
|
||||
"There were no substitution arguments "
|
||||
"but this format std::string has a $[0-9] in it");
|
||||
"but this format string has a $[0-9] in it");
|
||||
|
||||
std::string Substitute(const char* format, const substitute_internal::Arg& a0)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 1,
|
||||
"There was 1 substitution argument given, but "
|
||||
"this format std::string is either missing its $0, or "
|
||||
"this format string is either missing its $0, or "
|
||||
"contains one of $1-$9");
|
||||
|
||||
std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
||||
const substitute_internal::Arg& a1)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 3,
|
||||
"There were 2 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0/$1, or "
|
||||
"this format string is either missing its $0/$1, or "
|
||||
"contains one of $2-$9");
|
||||
|
||||
std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
||||
|
|
@ -606,7 +606,7 @@ std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
|||
const substitute_internal::Arg& a2)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 7,
|
||||
"There were 3 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0/$1/$2, or "
|
||||
"this format string is either missing its $0/$1/$2, or "
|
||||
"contains one of $3-$9");
|
||||
|
||||
std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
||||
|
|
@ -615,7 +615,7 @@ std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
|||
const substitute_internal::Arg& a3)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 15,
|
||||
"There were 4 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$3, or "
|
||||
"this format string is either missing its $0-$3, or "
|
||||
"contains one of $4-$9");
|
||||
|
||||
std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
||||
|
|
@ -625,7 +625,7 @@ std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
|||
const substitute_internal::Arg& a4)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 31,
|
||||
"There were 5 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$4, or "
|
||||
"this format string is either missing its $0-$4, or "
|
||||
"contains one of $5-$9");
|
||||
|
||||
std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
||||
|
|
@ -636,7 +636,7 @@ std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
|||
const substitute_internal::Arg& a5)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 63,
|
||||
"There were 6 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$5, or "
|
||||
"this format string is either missing its $0-$5, or "
|
||||
"contains one of $6-$9");
|
||||
|
||||
std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
||||
|
|
@ -648,7 +648,7 @@ std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
|||
const substitute_internal::Arg& a6)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 127,
|
||||
"There were 7 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$6, or "
|
||||
"this format string is either missing its $0-$6, or "
|
||||
"contains one of $7-$9");
|
||||
|
||||
std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
||||
|
|
@ -661,7 +661,7 @@ std::string Substitute(const char* format, const substitute_internal::Arg& a0,
|
|||
const substitute_internal::Arg& a7)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 255,
|
||||
"There were 8 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$7, or "
|
||||
"this format string is either missing its $0-$7, or "
|
||||
"contains one of $8-$9");
|
||||
|
||||
std::string Substitute(
|
||||
|
|
@ -673,7 +673,7 @@ std::string Substitute(
|
|||
ABSL_BAD_CALL_IF(
|
||||
substitute_internal::PlaceholderBitmask(format) != 511,
|
||||
"There were 9 substitution arguments given, but "
|
||||
"this format std::string is either missing its $0-$8, or contains a $9");
|
||||
"this format string is either missing its $0-$8, or contains a $9");
|
||||
|
||||
std::string Substitute(
|
||||
const char* format, const substitute_internal::Arg& a0,
|
||||
|
|
@ -684,7 +684,7 @@ std::string Substitute(
|
|||
const substitute_internal::Arg& a9)
|
||||
ABSL_BAD_CALL_IF(substitute_internal::PlaceholderBitmask(format) != 1023,
|
||||
"There were 10 substitution arguments given, but this "
|
||||
"format std::string doesn't contain all of $0 through $9");
|
||||
"format string doesn't contain all of $0 through $9");
|
||||
#endif // ABSL_BAD_CALL_IF
|
||||
|
||||
ABSL_NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ TEST(SubstituteTest, Substitute) {
|
|||
str = absl::Substitute("$0", char_buf);
|
||||
EXPECT_EQ("print me too", str);
|
||||
|
||||
// null char* is "doubly" special. Represented as the empty std::string.
|
||||
// null char* is "doubly" special. Represented as the empty string.
|
||||
char_p = nullptr;
|
||||
str = absl::Substitute("$0", char_p);
|
||||
EXPECT_EQ("", str);
|
||||
|
|
@ -189,14 +189,14 @@ TEST(SubstituteTest, VectorBoolRef) {
|
|||
TEST(SubstituteDeathTest, SubstituteDeath) {
|
||||
EXPECT_DEBUG_DEATH(
|
||||
static_cast<void>(absl::Substitute(absl::string_view("-$2"), "a", "b")),
|
||||
"Invalid absl::Substitute\\(\\) format std::string: asked for \"\\$2\", "
|
||||
"Invalid absl::Substitute\\(\\) format string: asked for \"\\$2\", "
|
||||
"but only 2 args were given.");
|
||||
EXPECT_DEBUG_DEATH(
|
||||
static_cast<void>(absl::Substitute(absl::string_view("-$z-"))),
|
||||
"Invalid absl::Substitute\\(\\) format std::string: \"-\\$z-\"");
|
||||
"Invalid absl::Substitute\\(\\) format string: \"-\\$z-\"");
|
||||
EXPECT_DEBUG_DEATH(
|
||||
static_cast<void>(absl::Substitute(absl::string_view("-$"))),
|
||||
"Invalid absl::Substitute\\(\\) format std::string: \"-\\$\"");
|
||||
"Invalid absl::Substitute\\(\\) format string: \"-\\$\"");
|
||||
}
|
||||
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue