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

Side by Side Diff: minidump/minidump_simple_string_dictionary_writer_test.cc

Issue 1483073004: Replace use of .Pass() with crashpad::move(). (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: pass: . Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "minidump/minidump_simple_string_dictionary_writer.h" 15 #include "minidump/minidump_simple_string_dictionary_writer.h"
16 16
17 #include <map> 17 #include <map>
18 #include <string> 18 #include <string>
19 19
20 #include "gtest/gtest.h" 20 #include "gtest/gtest.h"
21 #include "minidump/minidump_extensions.h" 21 #include "minidump/minidump_extensions.h"
22 #include "minidump/test/minidump_string_writer_test_util.h" 22 #include "minidump/test/minidump_string_writer_test_util.h"
23 #include "minidump/test/minidump_writable_test_util.h" 23 #include "minidump/test/minidump_writable_test_util.h"
24 #include "util/file/string_file.h" 24 #include "util/file/string_file.h"
25 #include "util/stdlib/move.h"
25 26
26 namespace crashpad { 27 namespace crashpad {
27 namespace test { 28 namespace test {
28 namespace { 29 namespace {
29 30
30 const MinidumpSimpleStringDictionary* MinidumpSimpleStringDictionaryAtStart( 31 const MinidumpSimpleStringDictionary* MinidumpSimpleStringDictionaryAtStart(
31 const std::string& file_contents, 32 const std::string& file_contents,
32 size_t count) { 33 size_t count) {
33 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor; 34 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
34 location_descriptor.DataSize = static_cast<uint32_t>( 35 location_descriptor.DataSize = static_cast<uint32_t>(
(...skipping 20 matching lines...) Expand all
55 ASSERT_TRUE(dictionary); 56 ASSERT_TRUE(dictionary);
56 EXPECT_EQ(0u, dictionary->count); 57 EXPECT_EQ(0u, dictionary->count);
57 } 58 }
58 59
59 TEST(MinidumpSimpleStringDictionaryWriter, EmptyKeyValue) { 60 TEST(MinidumpSimpleStringDictionaryWriter, EmptyKeyValue) {
60 StringFile string_file; 61 StringFile string_file;
61 62
62 MinidumpSimpleStringDictionaryWriter dictionary_writer; 63 MinidumpSimpleStringDictionaryWriter dictionary_writer;
63 auto entry_writer = 64 auto entry_writer =
64 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 65 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
65 dictionary_writer.AddEntry(entry_writer.Pass()); 66 dictionary_writer.AddEntry(crashpad::move(entry_writer));
66 67
67 EXPECT_TRUE(dictionary_writer.IsUseful()); 68 EXPECT_TRUE(dictionary_writer.IsUseful());
68 69
69 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file)); 70 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file));
70 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) + 71 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) +
71 sizeof(MinidumpSimpleStringDictionaryEntry) + 72 sizeof(MinidumpSimpleStringDictionaryEntry) +
72 2 * sizeof(MinidumpUTF8String) + 1 + 3 + 1, // 3 for padding 73 2 * sizeof(MinidumpUTF8String) + 1 + 3 + 1, // 3 for padding
73 string_file.string().size()); 74 string_file.string().size());
74 75
75 const MinidumpSimpleStringDictionary* dictionary = 76 const MinidumpSimpleStringDictionary* dictionary =
(...skipping 13 matching lines...) Expand all
89 TEST(MinidumpSimpleStringDictionaryWriter, OneKeyValue) { 90 TEST(MinidumpSimpleStringDictionaryWriter, OneKeyValue) {
90 StringFile string_file; 91 StringFile string_file;
91 92
92 char kKey[] = "key"; 93 char kKey[] = "key";
93 char kValue[] = "value"; 94 char kValue[] = "value";
94 95
95 MinidumpSimpleStringDictionaryWriter dictionary_writer; 96 MinidumpSimpleStringDictionaryWriter dictionary_writer;
96 auto entry_writer = 97 auto entry_writer =
97 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 98 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
98 entry_writer->SetKeyValue(kKey, kValue); 99 entry_writer->SetKeyValue(kKey, kValue);
99 dictionary_writer.AddEntry(entry_writer.Pass()); 100 dictionary_writer.AddEntry(crashpad::move(entry_writer));
100 101
101 EXPECT_TRUE(dictionary_writer.IsUseful()); 102 EXPECT_TRUE(dictionary_writer.IsUseful());
102 103
103 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file)); 104 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file));
104 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) + 105 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) +
105 sizeof(MinidumpSimpleStringDictionaryEntry) + 106 sizeof(MinidumpSimpleStringDictionaryEntry) +
106 2 * sizeof(MinidumpUTF8String) + sizeof(kKey) + sizeof(kValue), 107 2 * sizeof(MinidumpUTF8String) + sizeof(kKey) + sizeof(kValue),
107 string_file.string().size()); 108 string_file.string().size());
108 109
109 const MinidumpSimpleStringDictionary* dictionary = 110 const MinidumpSimpleStringDictionary* dictionary =
(...skipping 17 matching lines...) Expand all
127 char kValue0[] = "value0"; 128 char kValue0[] = "value0";
128 char kKey1[] = "zzz1"; 129 char kKey1[] = "zzz1";
129 char kValue1[] = "v1"; 130 char kValue1[] = "v1";
130 char kKey2[] = "aa2"; 131 char kKey2[] = "aa2";
131 char kValue2[] = "val2"; 132 char kValue2[] = "val2";
132 133
133 MinidumpSimpleStringDictionaryWriter dictionary_writer; 134 MinidumpSimpleStringDictionaryWriter dictionary_writer;
134 auto entry_writer_0 = 135 auto entry_writer_0 =
135 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 136 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
136 entry_writer_0->SetKeyValue(kKey0, kValue0); 137 entry_writer_0->SetKeyValue(kKey0, kValue0);
137 dictionary_writer.AddEntry(entry_writer_0.Pass()); 138 dictionary_writer.AddEntry(crashpad::move(entry_writer_0));
138 auto entry_writer_1 = 139 auto entry_writer_1 =
139 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 140 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
140 entry_writer_1->SetKeyValue(kKey1, kValue1); 141 entry_writer_1->SetKeyValue(kKey1, kValue1);
141 dictionary_writer.AddEntry(entry_writer_1.Pass()); 142 dictionary_writer.AddEntry(crashpad::move(entry_writer_1));
142 auto entry_writer_2 = 143 auto entry_writer_2 =
143 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 144 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
144 entry_writer_2->SetKeyValue(kKey2, kValue2); 145 entry_writer_2->SetKeyValue(kKey2, kValue2);
145 dictionary_writer.AddEntry(entry_writer_2.Pass()); 146 dictionary_writer.AddEntry(crashpad::move(entry_writer_2));
146 147
147 EXPECT_TRUE(dictionary_writer.IsUseful()); 148 EXPECT_TRUE(dictionary_writer.IsUseful());
148 149
149 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file)); 150 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file));
150 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) + 151 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) +
151 3 * sizeof(MinidumpSimpleStringDictionaryEntry) + 152 3 * sizeof(MinidumpSimpleStringDictionaryEntry) +
152 6 * sizeof(MinidumpUTF8String) + sizeof(kKey2) + 153 6 * sizeof(MinidumpUTF8String) + sizeof(kKey2) +
153 sizeof(kValue2) + 3 + sizeof(kKey0) + 1 + sizeof(kValue0) + 1 + 154 sizeof(kValue2) + 3 + sizeof(kKey0) + 1 + sizeof(kValue0) + 1 +
154 sizeof(kKey1) + 3 + sizeof(kValue1), 155 sizeof(kKey1) + 3 + sizeof(kValue1),
155 string_file.string().size()); 156 string_file.string().size());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 StringFile string_file; 196 StringFile string_file;
196 197
197 char kKey[] = "key"; 198 char kKey[] = "key";
198 char kValue0[] = "fake_value"; 199 char kValue0[] = "fake_value";
199 char kValue1[] = "value"; 200 char kValue1[] = "value";
200 201
201 MinidumpSimpleStringDictionaryWriter dictionary_writer; 202 MinidumpSimpleStringDictionaryWriter dictionary_writer;
202 auto entry_writer_0 = 203 auto entry_writer_0 =
203 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 204 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
204 entry_writer_0->SetKeyValue(kKey, kValue0); 205 entry_writer_0->SetKeyValue(kKey, kValue0);
205 dictionary_writer.AddEntry(entry_writer_0.Pass()); 206 dictionary_writer.AddEntry(crashpad::move(entry_writer_0));
206 auto entry_writer_1 = 207 auto entry_writer_1 =
207 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 208 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
208 entry_writer_1->SetKeyValue(kKey, kValue1); 209 entry_writer_1->SetKeyValue(kKey, kValue1);
209 dictionary_writer.AddEntry(entry_writer_1.Pass()); 210 dictionary_writer.AddEntry(crashpad::move(entry_writer_1));
210 211
211 EXPECT_TRUE(dictionary_writer.IsUseful()); 212 EXPECT_TRUE(dictionary_writer.IsUseful());
212 213
213 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file)); 214 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file));
214 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) + 215 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) +
215 sizeof(MinidumpSimpleStringDictionaryEntry) + 216 sizeof(MinidumpSimpleStringDictionaryEntry) +
216 2 * sizeof(MinidumpUTF8String) + sizeof(kKey) + sizeof(kValue1), 217 2 * sizeof(MinidumpUTF8String) + sizeof(kKey) + sizeof(kValue1),
217 string_file.string().size()); 218 string_file.string().size());
218 219
219 const MinidumpSimpleStringDictionary* dictionary = 220 const MinidumpSimpleStringDictionary* dictionary =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 MinidumpUTF8StringAtRVAAsString(string_file.string(), 279 MinidumpUTF8StringAtRVAAsString(string_file.string(),
279 dictionary->entries[2].key)); 280 dictionary->entries[2].key));
280 EXPECT_EQ(kValue2, 281 EXPECT_EQ(kValue2,
281 MinidumpUTF8StringAtRVAAsString(string_file.string(), 282 MinidumpUTF8StringAtRVAAsString(string_file.string(),
282 dictionary->entries[2].value)); 283 dictionary->entries[2].value));
283 } 284 }
284 285
285 } // namespace 286 } // namespace
286 } // namespace test 287 } // namespace test
287 } // namespace crashpad 288 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_simple_string_dictionary_writer.cc ('k') | minidump/minidump_string_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698