Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1126)

Unified Diff: minidump/minidump_string_writer_test.cc

Issue 936153002: Add FileReaderInterface. Move StringFileWriter to StringFile and (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Remove unused #include Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: minidump/minidump_string_writer_test.cc
diff --git a/minidump/minidump_string_writer_test.cc b/minidump/minidump_string_writer_test.cc
index 2bc87180ff35cc49c07b7ec2e7dfd9a1d80d7d32..aa8e48c6a3c77e3200713bc0be05f2da678c1ad7 100644
--- a/minidump/minidump_string_writer_test.cc
+++ b/minidump/minidump_string_writer_test.cc
@@ -30,27 +30,27 @@
#include "minidump/test/minidump_rva_list_test_util.h"
#include "minidump/test/minidump_string_writer_test_util.h"
#include "minidump/test/minidump_writable_test_util.h"
-#include "util/file/string_file_writer.h"
+#include "util/file/string_file.h"
namespace crashpad {
namespace test {
namespace {
TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) {
- StringFileWriter file_writer;
+ StringFile string_file;
{
SCOPED_TRACE("unset");
- file_writer.Reset();
+ string_file.Reset();
crashpad::internal::MinidumpUTF16StringWriter string_writer;
- EXPECT_TRUE(string_writer.WriteEverything(&file_writer));
- ASSERT_EQ(6u, file_writer.string().size());
+ EXPECT_TRUE(string_writer.WriteEverything(&string_file));
+ ASSERT_EQ(6u, string_file.string().size());
const MINIDUMP_STRING* minidump_string =
- MinidumpStringAtRVA(file_writer.string(), 0);
+ MinidumpStringAtRVA(string_file.string(), 0);
EXPECT_TRUE(minidump_string);
EXPECT_EQ(base::string16(),
- MinidumpStringAtRVAAsString(file_writer.string(), 0));
+ MinidumpStringAtRVAAsString(string_file.string(), 0));
}
const struct {
@@ -83,11 +83,11 @@ TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) {
kTestData[index]
.output_string[arraysize(kTestData[index].output_string) - 1]);
- file_writer.Reset();
+ string_file.Reset();
crashpad::internal::MinidumpUTF16StringWriter string_writer;
string_writer.SetUTF8(std::string(kTestData[index].input_string,
kTestData[index].input_length));
- EXPECT_TRUE(string_writer.WriteEverything(&file_writer));
+ EXPECT_TRUE(string_writer.WriteEverything(&string_file));
const size_t expected_utf16_units_with_nul =
kTestData[index].output_length + 1;
@@ -96,20 +96,20 @@ TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) {
const size_t expected_utf16_bytes =
expected_utf16_units_with_nul * sizeof(tmp.Buffer[0]);
ASSERT_EQ(sizeof(MINIDUMP_STRING) + expected_utf16_bytes,
- file_writer.string().size());
+ string_file.string().size());
const MINIDUMP_STRING* minidump_string =
- MinidumpStringAtRVA(file_writer.string(), 0);
+ MinidumpStringAtRVA(string_file.string(), 0);
EXPECT_TRUE(minidump_string);
base::string16 expect_string = base::string16(
kTestData[index].output_string, kTestData[index].output_length);
EXPECT_EQ(expect_string,
- MinidumpStringAtRVAAsString(file_writer.string(), 0));
+ MinidumpStringAtRVAAsString(string_file.string(), 0));
}
}
TEST(MinidumpStringWriter, ConvertInvalidUTF8ToUTF16) {
- StringFileWriter file_writer;
+ StringFile string_file;
const char* kTestData[] = {
"\200", // continuation byte
@@ -123,10 +123,10 @@ TEST(MinidumpStringWriter, ConvertInvalidUTF8ToUTF16) {
for (size_t index = 0; index < arraysize(kTestData); ++index) {
SCOPED_TRACE(base::StringPrintf(
"index %" PRIuS ", input %s", index, kTestData[index]));
- file_writer.Reset();
+ string_file.Reset();
crashpad::internal::MinidumpUTF16StringWriter string_writer;
string_writer.SetUTF8(kTestData[index]);
- EXPECT_TRUE(string_writer.WriteEverything(&file_writer));
+ EXPECT_TRUE(string_writer.WriteEverything(&string_file));
// The requirements for conversion of invalid UTF-8 input are lax. Make sure
// that at least enough data was written for a string that has one unit and
@@ -134,35 +134,35 @@ TEST(MinidumpStringWriter, ConvertInvalidUTF8ToUTF16) {
// data written, and make sure that at least one U+FFFD replacement
// character was written.
const MINIDUMP_STRING* minidump_string =
- MinidumpStringAtRVA(file_writer.string(), 0);
+ MinidumpStringAtRVA(string_file.string(), 0);
EXPECT_TRUE(minidump_string);
MINIDUMP_STRING tmp = {0};
ALLOW_UNUSED_LOCAL(tmp);
- EXPECT_EQ(file_writer.string().size() - sizeof(MINIDUMP_STRING) -
+ EXPECT_EQ(string_file.string().size() - sizeof(MINIDUMP_STRING) -
sizeof(tmp.Buffer[0]),
minidump_string->Length);
base::string16 output_string =
- MinidumpStringAtRVAAsString(file_writer.string(), 0);
+ MinidumpStringAtRVAAsString(string_file.string(), 0);
EXPECT_FALSE(output_string.empty());
EXPECT_NE(base::string16::npos, output_string.find(0xfffd));
}
}
TEST(MinidumpStringWriter, MinidumpUTF8StringWriter) {
- StringFileWriter file_writer;
+ StringFile string_file;
{
SCOPED_TRACE("unset");
- file_writer.Reset();
+ string_file.Reset();
crashpad::internal::MinidumpUTF8StringWriter string_writer;
- EXPECT_TRUE(string_writer.WriteEverything(&file_writer));
- ASSERT_EQ(5u, file_writer.string().size());
+ EXPECT_TRUE(string_writer.WriteEverything(&string_file));
+ ASSERT_EQ(5u, string_file.string().size());
const MinidumpUTF8String* minidump_string =
- MinidumpUTF8StringAtRVA(file_writer.string(), 0);
+ MinidumpUTF8StringAtRVA(string_file.string(), 0);
EXPECT_TRUE(minidump_string);
EXPECT_EQ(std::string(),
- MinidumpUTF8StringAtRVAAsString(file_writer.string(), 0));
+ MinidumpUTF8StringAtRVAAsString(string_file.string(), 0));
}
const struct {
@@ -186,22 +186,22 @@ TEST(MinidumpStringWriter, MinidumpUTF8StringWriter) {
SCOPED_TRACE(base::StringPrintf(
"index %" PRIuS ", input %s", index, kTestData[index].string));
- file_writer.Reset();
+ string_file.Reset();
crashpad::internal::MinidumpUTF8StringWriter string_writer;
std::string test_string(kTestData[index].string, kTestData[index].length);
string_writer.SetUTF8(test_string);
EXPECT_EQ(test_string, string_writer.UTF8());
- EXPECT_TRUE(string_writer.WriteEverything(&file_writer));
+ EXPECT_TRUE(string_writer.WriteEverything(&string_file));
const size_t expected_utf8_bytes_with_nul = kTestData[index].length + 1;
ASSERT_EQ(sizeof(MinidumpUTF8String) + expected_utf8_bytes_with_nul,
- file_writer.string().size());
+ string_file.string().size());
const MinidumpUTF8String* minidump_string =
- MinidumpUTF8StringAtRVA(file_writer.string(), 0);
+ MinidumpUTF8StringAtRVA(string_file.string(), 0);
EXPECT_TRUE(minidump_string);
EXPECT_EQ(test_string,
- MinidumpUTF8StringAtRVAAsString(file_writer.string(), 0));
+ MinidumpUTF8StringAtRVAAsString(string_file.string(), 0));
}
}
@@ -240,17 +240,17 @@ void MinidumpStringListTest() {
string_list_writer.InitializeFromVector(strings);
EXPECT_TRUE(string_list_writer.IsUseful());
- StringFileWriter file_writer;
+ StringFile string_file;
- ASSERT_TRUE(string_list_writer.WriteEverything(&file_writer));
+ ASSERT_TRUE(string_list_writer.WriteEverything(&string_file));
const MinidumpRVAList* list =
- MinidumpRVAListAtStart(file_writer.string(), strings.size());
+ MinidumpRVAListAtStart(string_file.string(), strings.size());
ASSERT_TRUE(list);
for (size_t index = 0; index < strings.size(); ++index) {
EXPECT_EQ(Traits::ExpectationForUTF8(strings[index]),
- Traits::ObservationAtRVA(file_writer.string(),
+ Traits::ObservationAtRVA(string_file.string(),
list->children[index]));
}
}
« no previous file with comments | « minidump/minidump_simple_string_dictionary_writer_test.cc ('k') | minidump/minidump_system_info_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698