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

Unified Diff: minidump/minidump_simple_string_dictionary_writer_test.cc

Issue 670853002: minidump: Migrate the rest of the tests to MinidumpWritableAtLocationDescriptor<>() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years, 2 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
« no previous file with comments | « minidump/minidump_module_writer_test.cc ('k') | minidump/minidump_system_info_writer_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: minidump/minidump_simple_string_dictionary_writer_test.cc
diff --git a/minidump/minidump_simple_string_dictionary_writer_test.cc b/minidump/minidump_simple_string_dictionary_writer_test.cc
index bbe247652978a1b70521da9664fcda2d0c0bba0d..7ab62a8708082a4f8ec55d4e9b9fa1f192b4601a 100644
--- a/minidump/minidump_simple_string_dictionary_writer_test.cc
+++ b/minidump/minidump_simple_string_dictionary_writer_test.cc
@@ -19,16 +19,23 @@
#include "gtest/gtest.h"
#include "minidump/minidump_extensions.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"
namespace crashpad {
namespace test {
namespace {
-const MinidumpSimpleStringDictionary* MinidumpSimpleStringDictionaryCast(
- const StringFileWriter& file_writer) {
- return reinterpret_cast<const MinidumpSimpleStringDictionary*>(
- &file_writer.string()[0]);
+const MinidumpSimpleStringDictionary* MinidumpSimpleStringDictionaryAtStart(
+ const std::string& file_contents,
+ size_t count) {
+ MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
+ location_descriptor.DataSize =
+ sizeof(MinidumpSimpleStringDictionary) +
+ count * sizeof(MinidumpSimpleStringDictionaryEntry);
+ location_descriptor.Rva = 0;
+ return MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
+ file_contents, location_descriptor);
}
TEST(MinidumpSimpleStringDictionaryWriter, EmptySimpleStringDictionary) {
@@ -41,7 +48,8 @@ TEST(MinidumpSimpleStringDictionaryWriter, EmptySimpleStringDictionary) {
file_writer.string().size());
const MinidumpSimpleStringDictionary* dictionary =
- MinidumpSimpleStringDictionaryCast(file_writer);
+ MinidumpSimpleStringDictionaryAtStart(file_writer.string(), 0);
+ ASSERT_TRUE(dictionary);
EXPECT_EQ(0u, dictionary->count);
}
@@ -59,7 +67,8 @@ TEST(MinidumpSimpleStringDictionaryWriter, EmptyKeyValue) {
file_writer.string().size());
const MinidumpSimpleStringDictionary* dictionary =
- MinidumpSimpleStringDictionaryCast(file_writer);
+ MinidumpSimpleStringDictionaryAtStart(file_writer.string(), 1);
+ ASSERT_TRUE(dictionary);
EXPECT_EQ(1u, dictionary->count);
EXPECT_EQ(12u, dictionary->entries[0].key);
EXPECT_EQ(20u, dictionary->entries[0].value);
@@ -89,7 +98,8 @@ TEST(MinidumpSimpleStringDictionaryWriter, OneKeyValue) {
file_writer.string().size());
const MinidumpSimpleStringDictionary* dictionary =
- MinidumpSimpleStringDictionaryCast(file_writer);
+ MinidumpSimpleStringDictionaryAtStart(file_writer.string(), 1);
+ ASSERT_TRUE(dictionary);
EXPECT_EQ(1u, dictionary->count);
EXPECT_EQ(12u, dictionary->entries[0].key);
EXPECT_EQ(20u, dictionary->entries[0].value);
@@ -131,7 +141,8 @@ TEST(MinidumpSimpleStringDictionaryWriter, ThreeKeysValues) {
file_writer.string().size());
const MinidumpSimpleStringDictionary* dictionary =
- MinidumpSimpleStringDictionaryCast(file_writer);
+ MinidumpSimpleStringDictionaryAtStart(file_writer.string(), 3);
+ ASSERT_TRUE(dictionary);
EXPECT_EQ(3u, dictionary->count);
EXPECT_EQ(28u, dictionary->entries[0].key);
EXPECT_EQ(36u, dictionary->entries[0].value);
@@ -188,7 +199,8 @@ TEST(MinidumpSimpleStringDictionaryWriter, DuplicateKeyValue) {
file_writer.string().size());
const MinidumpSimpleStringDictionary* dictionary =
- MinidumpSimpleStringDictionaryCast(file_writer);
+ MinidumpSimpleStringDictionaryAtStart(file_writer.string(), 1);
+ ASSERT_TRUE(dictionary);
EXPECT_EQ(1u, dictionary->count);
EXPECT_EQ(12u, dictionary->entries[0].key);
EXPECT_EQ(20u, dictionary->entries[0].value);
« no previous file with comments | « minidump/minidump_module_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