mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 15:32:10 +08:00
Move string16 and char16 in to base::
Needs to include roll with https://codereview.chromium.org/803593002/ included. R=mark@chromium.org Review URL: https://codereview.chromium.org/804593002
This commit is contained in:
parent
1c4084fc2d
commit
af07f4022b
2
DEPS
2
DEPS
@ -28,7 +28,7 @@ deps = {
|
||||
'46282cedf40ff7fe803be4af357b9d59050f02e4', # svn r1977
|
||||
'crashpad/third_party/mini_chromium/mini_chromium':
|
||||
Var('chromium_git') + '/chromium/mini_chromium@' +
|
||||
'9427a679aa584c939103b91f77782998f841ec01',
|
||||
'37bac7bdca4c266468126cafe8a30069c3fc2917'
|
||||
}
|
||||
|
||||
hooks = [
|
||||
|
@ -134,7 +134,7 @@ struct __attribute__((packed, aligned(4))) MINIDUMP_STRING {
|
||||
|
||||
//! \brief The string, encoded in UTF-16, and terminated with a UTF-16 `NUL`
|
||||
//! code unit (two `NUL` bytes).
|
||||
char16 Buffer[0];
|
||||
base::char16 Buffer[0];
|
||||
};
|
||||
|
||||
//! \brief Minidump stream type values for MINIDUMP_DIRECTORY::StreamType. Each
|
||||
@ -809,7 +809,7 @@ struct __attribute__((packed, aligned(4))) MINIDUMP_MISC_INFO_4
|
||||
//!
|
||||
//! On Windows 8.1 (NT 6.3), this is “6.3.9600.17031
|
||||
//! (winblue_gdr.140221-1952)”.
|
||||
char16 BuildString[260];
|
||||
base::char16 BuildString[260];
|
||||
|
||||
//! \brief The minidump producer’s “build string”, a string identifying the
|
||||
//! module that produced a minidump file.
|
||||
@ -818,7 +818,7 @@ struct __attribute__((packed, aligned(4))) MINIDUMP_MISC_INFO_4
|
||||
//!
|
||||
//! On Windows 8.1 (NT 6.3), this may be “dbghelp.i386,6.3.9600.16520” or
|
||||
//! “dbghelp.amd64,6.3.9600.16520” depending on CPU architecture.
|
||||
char16 DbgBldStr[40];
|
||||
base::char16 DbgBldStr[40];
|
||||
};
|
||||
|
||||
//! \brief The latest known version of the MINIDUMP_MISC_INFO structure.
|
||||
|
@ -27,7 +27,7 @@ struct TIME_ZONE_INFORMATION {
|
||||
|
||||
//! \brief The UTF-16-encoded name of the time zone when observing standard
|
||||
//! time.
|
||||
char16 StandardName[32];
|
||||
base::char16 StandardName[32];
|
||||
|
||||
//! \brief The date and time to switch from daylight saving time to standard
|
||||
//! time.
|
||||
@ -45,7 +45,7 @@ struct TIME_ZONE_INFORMATION {
|
||||
|
||||
//! \brief The UTF-16-encoded name of the time zone when observing daylight
|
||||
//! saving time.
|
||||
char16 DaylightName[32];
|
||||
base::char16 DaylightName[32];
|
||||
|
||||
//! \brief The date and time to switch from standard time to daylight saving
|
||||
//! time.
|
||||
|
@ -60,11 +60,11 @@ void GetMiscInfoStream(const std::string& file_contents, const T** misc_info) {
|
||||
ASSERT_TRUE(misc_info);
|
||||
}
|
||||
|
||||
void ExpectNULPaddedString16Equal(const char16* expected,
|
||||
const char16* observed,
|
||||
void ExpectNULPaddedString16Equal(const base::char16* expected,
|
||||
const base::char16* observed,
|
||||
size_t size) {
|
||||
string16 expected_string(expected, size);
|
||||
string16 observed_string(observed, size);
|
||||
base::string16 expected_string(expected, size);
|
||||
base::string16 observed_string(observed, size);
|
||||
EXPECT_EQ(expected_string, observed_string);
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ TEST(MinidumpMiscInfoWriter, TimeZone) {
|
||||
expected.Flags1 = MINIDUMP_MISC3_TIMEZONE;
|
||||
expected.TimeZoneId = kTimeZoneId;
|
||||
expected.TimeZone.Bias = kBias;
|
||||
string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
||||
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
||||
c16lcpy(expected.TimeZone.StandardName,
|
||||
standard_name_utf16.c_str(),
|
||||
arraysize(expected.TimeZone.StandardName));
|
||||
@ -370,7 +370,7 @@ TEST(MinidumpMiscInfoWriter, TimeZone) {
|
||||
&kStandardDate,
|
||||
sizeof(expected.TimeZone.StandardDate));
|
||||
expected.TimeZone.StandardBias = kStandardBias;
|
||||
string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
||||
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
||||
c16lcpy(expected.TimeZone.DaylightName,
|
||||
daylight_name_utf16.c_str(),
|
||||
arraysize(expected.TimeZone.DaylightName));
|
||||
@ -424,7 +424,7 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
|
||||
expected.Flags1 = MINIDUMP_MISC3_TIMEZONE;
|
||||
expected.TimeZoneId = kTimeZoneId;
|
||||
expected.TimeZone.Bias = kBias;
|
||||
string16 standard_name_utf16 = base::UTF8ToUTF16(standard_name);
|
||||
base::string16 standard_name_utf16 = base::UTF8ToUTF16(standard_name);
|
||||
c16lcpy(expected.TimeZone.StandardName,
|
||||
standard_name_utf16.c_str(),
|
||||
arraysize(expected.TimeZone.StandardName));
|
||||
@ -432,7 +432,7 @@ TEST(MinidumpMiscInfoWriter, TimeZoneStringsOverflow) {
|
||||
&kSystemTimeZero,
|
||||
sizeof(expected.TimeZone.StandardDate));
|
||||
expected.TimeZone.StandardBias = kStandardBias;
|
||||
string16 daylight_name_utf16 = base::UTF8ToUTF16(daylight_name);
|
||||
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(daylight_name);
|
||||
c16lcpy(expected.TimeZone.DaylightName,
|
||||
daylight_name_utf16.c_str(),
|
||||
arraysize(expected.TimeZone.DaylightName));
|
||||
@ -463,11 +463,12 @@ TEST(MinidumpMiscInfoWriter, BuildStrings) {
|
||||
|
||||
MINIDUMP_MISC_INFO_4 expected = {};
|
||||
expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING;
|
||||
string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
||||
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
||||
c16lcpy(expected.BuildString,
|
||||
build_string_utf16.c_str(),
|
||||
arraysize(expected.BuildString));
|
||||
string16 debug_build_string_utf16 = base::UTF8ToUTF16(kDebugBuildString);
|
||||
base::string16 debug_build_string_utf16 =
|
||||
base::UTF8ToUTF16(kDebugBuildString);
|
||||
c16lcpy(expected.DbgBldStr,
|
||||
debug_build_string_utf16.c_str(),
|
||||
arraysize(expected.DbgBldStr));
|
||||
@ -499,11 +500,12 @@ TEST(MinidumpMiscInfoWriter, BuildStringsOverflow) {
|
||||
|
||||
MINIDUMP_MISC_INFO_4 expected = {};
|
||||
expected.Flags1 = MINIDUMP_MISC4_BUILDSTRING;
|
||||
string16 build_string_utf16 = base::UTF8ToUTF16(build_string);
|
||||
base::string16 build_string_utf16 = base::UTF8ToUTF16(build_string);
|
||||
c16lcpy(expected.BuildString,
|
||||
build_string_utf16.c_str(),
|
||||
arraysize(expected.BuildString));
|
||||
string16 debug_build_string_utf16 = base::UTF8ToUTF16(debug_build_string);
|
||||
base::string16 debug_build_string_utf16 =
|
||||
base::UTF8ToUTF16(debug_build_string);
|
||||
c16lcpy(expected.DbgBldStr,
|
||||
debug_build_string_utf16.c_str(),
|
||||
arraysize(expected.DbgBldStr));
|
||||
@ -586,7 +588,7 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
||||
expected.ProtectedProcess = kProtectedProcess;
|
||||
expected.TimeZoneId = kTimeZoneId;
|
||||
expected.TimeZone.Bias = kBias;
|
||||
string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
||||
base::string16 standard_name_utf16 = base::UTF8ToUTF16(kStandardName);
|
||||
c16lcpy(expected.TimeZone.StandardName,
|
||||
standard_name_utf16.c_str(),
|
||||
arraysize(expected.TimeZone.StandardName));
|
||||
@ -594,7 +596,7 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
||||
&kSystemTimeZero,
|
||||
sizeof(expected.TimeZone.StandardDate));
|
||||
expected.TimeZone.StandardBias = kStandardBias;
|
||||
string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
||||
base::string16 daylight_name_utf16 = base::UTF8ToUTF16(kDaylightName);
|
||||
c16lcpy(expected.TimeZone.DaylightName,
|
||||
daylight_name_utf16.c_str(),
|
||||
arraysize(expected.TimeZone.DaylightName));
|
||||
@ -602,11 +604,12 @@ TEST(MinidumpMiscInfoWriter, Everything) {
|
||||
&kSystemTimeZero,
|
||||
sizeof(expected.TimeZone.DaylightDate));
|
||||
expected.TimeZone.DaylightBias = kDaylightBias;
|
||||
string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
||||
base::string16 build_string_utf16 = base::UTF8ToUTF16(kBuildString);
|
||||
c16lcpy(expected.BuildString,
|
||||
build_string_utf16.c_str(),
|
||||
arraysize(expected.BuildString));
|
||||
string16 debug_build_string_utf16 = base::UTF8ToUTF16(kDebugBuildString);
|
||||
base::string16 debug_build_string_utf16 =
|
||||
base::UTF8ToUTF16(kDebugBuildString);
|
||||
c16lcpy(expected.DbgBldStr,
|
||||
debug_build_string_utf16.c_str(),
|
||||
arraysize(expected.DbgBldStr));
|
||||
@ -625,13 +628,16 @@ TEST(MinidumpMiscInfoWriter, InitializeFromSnapshot) {
|
||||
"Sun Aug 17 19:50:11 PDT 2014; "
|
||||
"root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64";
|
||||
const char kMachineDescription[] = "MacBookPro11,3 (Mac-2BD1B31983FE1663)";
|
||||
string16 standard_time_name_utf16 = base::UTF8ToUTF16(kStandardTimeName);
|
||||
string16 daylight_time_name_utf16 = base::UTF8ToUTF16(kDaylightTimeName);
|
||||
string16 build_string_utf16 = base::UTF8ToUTF16(
|
||||
base::string16 standard_time_name_utf16 =
|
||||
base::UTF8ToUTF16(kStandardTimeName);
|
||||
base::string16 daylight_time_name_utf16 =
|
||||
base::UTF8ToUTF16(kDaylightTimeName);
|
||||
base::string16 build_string_utf16 = base::UTF8ToUTF16(
|
||||
std::string(kOSVersionFull) + "; " + kMachineDescription);
|
||||
std::string debug_build_string = internal::MinidumpMiscInfoDebugBuildString();
|
||||
EXPECT_FALSE(debug_build_string.empty());
|
||||
string16 debug_build_string_utf16 = base::UTF8ToUTF16(debug_build_string);
|
||||
base::string16 debug_build_string_utf16 =
|
||||
base::UTF8ToUTF16(debug_build_string);
|
||||
|
||||
expect_misc_info.SizeOfInfo = sizeof(expect_misc_info);
|
||||
expect_misc_info.Flags1 = MINIDUMP_MISC1_PROCESS_ID |
|
||||
|
@ -172,7 +172,7 @@ class MinidumpModuleMiscDebugRecordWriter final
|
||||
private:
|
||||
IMAGE_DEBUG_MISC image_debug_misc_;
|
||||
std::string data_;
|
||||
string16 data_utf16_;
|
||||
base::string16 data_utf16_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MinidumpModuleMiscDebugRecordWriter);
|
||||
};
|
||||
|
@ -172,9 +172,9 @@ void ExpectMiscellaneousDebugRecord(
|
||||
|
||||
size_t bytes_used;
|
||||
if (misc_debug_record->Unicode) {
|
||||
string16 observed_data_utf16(
|
||||
reinterpret_cast<const char16*>(misc_debug_record->Data));
|
||||
bytes_used = (observed_data_utf16.size() + 1) * sizeof(char16);
|
||||
base::string16 observed_data_utf16(
|
||||
reinterpret_cast<const base::char16*>(misc_debug_record->Data));
|
||||
bytes_used = (observed_data_utf16.size() + 1) * sizeof(base::char16);
|
||||
observed_data = base::UTF16ToUTF8(observed_data_utf16);
|
||||
} else {
|
||||
observed_data = reinterpret_cast<const char*>(misc_debug_record->Data);
|
||||
@ -247,9 +247,10 @@ void ExpectModule(const MINIDUMP_MODULE* expected,
|
||||
EXPECT_EQ(0u, observed->Reserved1);
|
||||
|
||||
EXPECT_NE(0u, observed->ModuleNameRva);
|
||||
string16 observed_module_name_utf16 =
|
||||
base::string16 observed_module_name_utf16 =
|
||||
MinidumpStringAtRVAAsString(file_contents, observed->ModuleNameRva);
|
||||
string16 expected_module_name_utf16 = base::UTF8ToUTF16(expected_module_name);
|
||||
base::string16 expected_module_name_utf16 =
|
||||
base::UTF8ToUTF16(expected_module_name);
|
||||
EXPECT_EQ(expected_module_name_utf16, observed_module_name_utf16);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectCodeViewRecord(&observed->CvRecord,
|
||||
|
@ -32,7 +32,7 @@ namespace internal {
|
||||
//! \cond
|
||||
|
||||
struct MinidumpStringWriterUTF16Traits {
|
||||
using StringType = string16;
|
||||
using StringType = base::string16;
|
||||
using MinidumpStringType = MINIDUMP_STRING;
|
||||
};
|
||||
|
||||
|
@ -46,14 +46,15 @@ TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) {
|
||||
const MINIDUMP_STRING* minidump_string =
|
||||
MinidumpStringAtRVA(file_writer.string(), 0);
|
||||
EXPECT_TRUE(minidump_string);
|
||||
EXPECT_EQ(string16(), MinidumpStringAtRVAAsString(file_writer.string(), 0));
|
||||
EXPECT_EQ(base::string16(),
|
||||
MinidumpStringAtRVAAsString(file_writer.string(), 0));
|
||||
}
|
||||
|
||||
const struct {
|
||||
size_t input_length;
|
||||
const char* input_string;
|
||||
size_t output_length;
|
||||
const char16 output_string[10];
|
||||
const base::char16 output_string[10];
|
||||
} kTestData[] = {
|
||||
{0, "", 0, {}},
|
||||
{1, "a", 1, {'a'}},
|
||||
@ -95,8 +96,8 @@ TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) {
|
||||
const MINIDUMP_STRING* minidump_string =
|
||||
MinidumpStringAtRVA(file_writer.string(), 0);
|
||||
EXPECT_TRUE(minidump_string);
|
||||
string16 expect_string = string16(kTestData[index].output_string,
|
||||
kTestData[index].output_length);
|
||||
base::string16 expect_string = base::string16(
|
||||
kTestData[index].output_string, kTestData[index].output_length);
|
||||
EXPECT_EQ(expect_string,
|
||||
MinidumpStringAtRVAAsString(file_writer.string(), 0));
|
||||
}
|
||||
@ -133,10 +134,10 @@ TEST(MinidumpStringWriter, ConvertInvalidUTF8ToUTF16) {
|
||||
EXPECT_EQ(file_writer.string().size() - sizeof(MINIDUMP_STRING) -
|
||||
sizeof(MINIDUMP_STRING::Buffer[0]),
|
||||
minidump_string->Length);
|
||||
string16 output_string =
|
||||
base::string16 output_string =
|
||||
MinidumpStringAtRVAAsString(file_writer.string(), 0);
|
||||
EXPECT_FALSE(output_string.empty());
|
||||
EXPECT_NE(string16::npos, output_string.find(0xfffd));
|
||||
EXPECT_NE(base::string16::npos, output_string.find(0xfffd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,10 +200,11 @@ TEST(MinidumpStringWriter, MinidumpUTF8StringWriter) {
|
||||
|
||||
struct MinidumpUTF16StringListWriterTraits {
|
||||
using MinidumpStringListWriterType = MinidumpUTF16StringListWriter;
|
||||
static string16 ExpectationForUTF8(const std::string& utf8) {
|
||||
static base::string16 ExpectationForUTF8(const std::string& utf8) {
|
||||
return base::UTF8ToUTF16(utf8);
|
||||
}
|
||||
static string16 ObservationAtRVA(const std::string& file_contents, RVA rva) {
|
||||
static base::string16 ObservationAtRVA(const std::string& file_contents,
|
||||
RVA rva) {
|
||||
return MinidumpStringAtRVAAsString(file_contents, rva);
|
||||
}
|
||||
};
|
||||
|
@ -32,8 +32,8 @@ void MinidumpWriterUtil::AssignTimeT(uint32_t* destination, time_t source) {
|
||||
}
|
||||
|
||||
// static
|
||||
string16 MinidumpWriterUtil::ConvertUTF8ToUTF16(const std::string& utf8) {
|
||||
string16 utf16;
|
||||
base::string16 MinidumpWriterUtil::ConvertUTF8ToUTF16(const std::string& utf8) {
|
||||
base::string16 utf16;
|
||||
if (!base::UTF8ToUTF16(utf8.data(), utf8.length(), &utf16)) {
|
||||
LOG(WARNING) << "string " << utf8
|
||||
<< " cannot be converted to UTF-16 losslessly";
|
||||
@ -42,10 +42,10 @@ string16 MinidumpWriterUtil::ConvertUTF8ToUTF16(const std::string& utf8) {
|
||||
}
|
||||
|
||||
// static
|
||||
void MinidumpWriterUtil::AssignUTF8ToUTF16(char16* destination,
|
||||
void MinidumpWriterUtil::AssignUTF8ToUTF16(base::char16* destination,
|
||||
size_t destination_size,
|
||||
const std::string& source) {
|
||||
string16 source_utf16 = ConvertUTF8ToUTF16(source);
|
||||
base::string16 source_utf16 = ConvertUTF8ToUTF16(source);
|
||||
if (source_utf16.size() > destination_size - 1) {
|
||||
LOG(WARNING) << "string " << source << " UTF-16 length "
|
||||
<< source_utf16.size()
|
||||
|
@ -57,7 +57,7 @@ class MinidumpWriterUtil final {
|
||||
//! \return The \a utf8 string, converted to UTF-16 encoding. If the
|
||||
//! conversion is lossy, U+FFFD “replacement characters” will be
|
||||
//! introduced.
|
||||
static string16 ConvertUTF8ToUTF16(const std::string& utf8);
|
||||
static base::string16 ConvertUTF8ToUTF16(const std::string& utf8);
|
||||
|
||||
//! \brief Converts a UTF-8 string to UTF-16 and places it into a buffer of
|
||||
//! fixed size, taking care to `NUL`-terminate the buffer and not to
|
||||
@ -76,7 +76,7 @@ class MinidumpWriterUtil final {
|
||||
//! \param[in] destination_size The size of \a destination in `char16` units,
|
||||
//! including space used by a `NUL` terminator.
|
||||
//! \param[in] source The UTF-8-encoded input string.
|
||||
static void AssignUTF8ToUTF16(char16* destination,
|
||||
static void AssignUTF8ToUTF16(base::char16* destination,
|
||||
size_t destination_size,
|
||||
const std::string& source);
|
||||
|
||||
|
@ -89,10 +89,10 @@ const MinidumpUTF8String* MinidumpUTF8StringAtRVA(
|
||||
return TMinidumpStringAtRVA<MinidumpUTF8String>(file_contents, rva);
|
||||
}
|
||||
|
||||
string16 MinidumpStringAtRVAAsString(const std::string& file_contents,
|
||||
RVA rva) {
|
||||
return TMinidumpStringAtRVAAsString<string16, MINIDUMP_STRING>(file_contents,
|
||||
rva);
|
||||
base::string16 MinidumpStringAtRVAAsString(const std::string& file_contents,
|
||||
RVA rva) {
|
||||
return TMinidumpStringAtRVAAsString<base::string16, MINIDUMP_STRING>(
|
||||
file_contents, rva);
|
||||
}
|
||||
|
||||
std::string MinidumpUTF8StringAtRVAAsString(const std::string& file_contents,
|
||||
|
@ -78,7 +78,8 @@ const MinidumpUTF8String* MinidumpUTF8StringAtRVA(
|
||||
//! failure, raises a gtest assertion and returns an empty string.
|
||||
//!
|
||||
//! \sa MinidumpUTF8StringAtRVAAsString()
|
||||
string16 MinidumpStringAtRVAAsString(const std::string& file_contents, RVA rva);
|
||||
base::string16 MinidumpStringAtRVAAsString(const std::string& file_contents,
|
||||
RVA rva);
|
||||
|
||||
//! \brief Returns the contents of a MinidumpUTF8String as a `std::string`.
|
||||
//!
|
||||
|
@ -110,14 +110,16 @@ const IMAGE_DEBUG_MISC* MinidumpWritableAtLocationDescriptor<IMAGE_DEBUG_MISC>(
|
||||
return nullptr;
|
||||
}
|
||||
} else if (misc->Unicode == 1) {
|
||||
if (misc->Length % sizeof(char16) != 0) {
|
||||
EXPECT_EQ(0u, misc->Length % sizeof(char16));
|
||||
if (misc->Length % sizeof(base::char16) != 0) {
|
||||
EXPECT_EQ(0u, misc->Length % sizeof(base::char16));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t string_length =
|
||||
(misc->Length - offsetof(IMAGE_DEBUG_MISC, Data)) / sizeof(char16) - 1;
|
||||
const char16* data16 = reinterpret_cast<const char16*>(misc->Data);
|
||||
size_t string_length = (misc->Length - offsetof(IMAGE_DEBUG_MISC, Data)) /
|
||||
sizeof(base::char16) -
|
||||
1;
|
||||
const base::char16* data16 =
|
||||
reinterpret_cast<const base::char16*>(misc->Data);
|
||||
if (data16[string_length] != '\0') {
|
||||
EXPECT_EQ('\0', data16[string_length]);
|
||||
return nullptr;
|
||||
|
@ -16,7 +16,9 @@
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
size_t c16lcpy(char16* destination, const char16* source, size_t length) {
|
||||
size_t c16lcpy(base::char16* destination,
|
||||
const base::char16* source,
|
||||
size_t length) {
|
||||
size_t source_length = base::c16len(source);
|
||||
if (source_length < length) {
|
||||
base::c16memcpy(destination, source, source_length + 1);
|
||||
|
@ -45,7 +45,9 @@ namespace crashpad {
|
||||
//! \return The length of the \a source string in char16 units, not including
|
||||
//! its `NUL` terminator. When truncation occurs, the return value will be
|
||||
//! equal to or greater than than the \a length parameter.
|
||||
size_t c16lcpy(char16* destination, const char16* source, size_t length);
|
||||
size_t c16lcpy(base::char16* destination,
|
||||
const base::char16* source,
|
||||
size_t length);
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
|
@ -31,24 +31,24 @@ TEST(strlcpy, c16lcpy) {
|
||||
// Use a destination buffer that’s larger than the length passed to c16lcpy.
|
||||
// The unused portion is a guard area that must not be written to.
|
||||
struct TestBuffer {
|
||||
char16 lead_guard[64];
|
||||
char16 data[128];
|
||||
char16 trail_guard[64];
|
||||
base::char16 lead_guard[64];
|
||||
base::char16 data[128];
|
||||
base::char16 trail_guard[64];
|
||||
};
|
||||
TestBuffer expected_untouched;
|
||||
memset(&expected_untouched, 0xa5, sizeof(expected_untouched));
|
||||
|
||||
// Test with M, é, Ā, ő, and Ḙ. This is a mix of characters that have zero and
|
||||
// nonzero low and high bytes.
|
||||
const char16 test_characters[] = {0x4d, 0xe9, 0x100, 0x151, 0x1e18};
|
||||
const base::char16 test_characters[] = {0x4d, 0xe9, 0x100, 0x151, 0x1e18};
|
||||
|
||||
for (size_t index = 0; index < arraysize(test_characters); ++index) {
|
||||
char16 test_character = test_characters[index];
|
||||
base::char16 test_character = test_characters[index];
|
||||
SCOPED_TRACE(base::StringPrintf(
|
||||
"character index %zu, character 0x%x", index, test_character));
|
||||
for (size_t length = 0; length < 256; ++length) {
|
||||
SCOPED_TRACE(base::StringPrintf("index %zu", length));
|
||||
string16 test_string(length, test_character);
|
||||
base::string16 test_string(length, test_character);
|
||||
|
||||
TestBuffer destination;
|
||||
memset(&destination, 0xa5, sizeof(destination));
|
||||
|
Loading…
x
Reference in New Issue
Block a user