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

Side by Side Diff: minidump/minidump_simple_string_dictionary_writer_test.cc

Issue 1513573005: Provide std::move() in compat instead of using crashpad::move() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: 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 #include <utility>
19 20
20 #include "gtest/gtest.h" 21 #include "gtest/gtest.h"
21 #include "minidump/minidump_extensions.h" 22 #include "minidump/minidump_extensions.h"
22 #include "minidump/test/minidump_string_writer_test_util.h" 23 #include "minidump/test/minidump_string_writer_test_util.h"
23 #include "minidump/test/minidump_writable_test_util.h" 24 #include "minidump/test/minidump_writable_test_util.h"
24 #include "util/file/string_file.h" 25 #include "util/file/string_file.h"
25 #include "util/stdlib/move.h"
26 26
27 namespace crashpad { 27 namespace crashpad {
28 namespace test { 28 namespace test {
29 namespace { 29 namespace {
30 30
31 const MinidumpSimpleStringDictionary* MinidumpSimpleStringDictionaryAtStart( 31 const MinidumpSimpleStringDictionary* MinidumpSimpleStringDictionaryAtStart(
32 const std::string& file_contents, 32 const std::string& file_contents,
33 size_t count) { 33 size_t count) {
34 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor; 34 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
35 location_descriptor.DataSize = static_cast<uint32_t>( 35 location_descriptor.DataSize = static_cast<uint32_t>(
(...skipping 20 matching lines...) Expand all
56 ASSERT_TRUE(dictionary); 56 ASSERT_TRUE(dictionary);
57 EXPECT_EQ(0u, dictionary->count); 57 EXPECT_EQ(0u, dictionary->count);
58 } 58 }
59 59
60 TEST(MinidumpSimpleStringDictionaryWriter, EmptyKeyValue) { 60 TEST(MinidumpSimpleStringDictionaryWriter, EmptyKeyValue) {
61 StringFile string_file; 61 StringFile string_file;
62 62
63 MinidumpSimpleStringDictionaryWriter dictionary_writer; 63 MinidumpSimpleStringDictionaryWriter dictionary_writer;
64 auto entry_writer = 64 auto entry_writer =
65 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 65 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
66 dictionary_writer.AddEntry(crashpad::move(entry_writer)); 66 dictionary_writer.AddEntry(std::move(entry_writer));
67 67
68 EXPECT_TRUE(dictionary_writer.IsUseful()); 68 EXPECT_TRUE(dictionary_writer.IsUseful());
69 69
70 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file)); 70 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file));
71 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) + 71 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) +
72 sizeof(MinidumpSimpleStringDictionaryEntry) + 72 sizeof(MinidumpSimpleStringDictionaryEntry) +
73 2 * sizeof(MinidumpUTF8String) + 1 + 3 + 1, // 3 for padding 73 2 * sizeof(MinidumpUTF8String) + 1 + 3 + 1, // 3 for padding
74 string_file.string().size()); 74 string_file.string().size());
75 75
76 const MinidumpSimpleStringDictionary* dictionary = 76 const MinidumpSimpleStringDictionary* dictionary =
(...skipping 13 matching lines...) Expand all
90 TEST(MinidumpSimpleStringDictionaryWriter, OneKeyValue) { 90 TEST(MinidumpSimpleStringDictionaryWriter, OneKeyValue) {
91 StringFile string_file; 91 StringFile string_file;
92 92
93 char kKey[] = "key"; 93 char kKey[] = "key";
94 char kValue[] = "value"; 94 char kValue[] = "value";
95 95
96 MinidumpSimpleStringDictionaryWriter dictionary_writer; 96 MinidumpSimpleStringDictionaryWriter dictionary_writer;
97 auto entry_writer = 97 auto entry_writer =
98 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 98 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
99 entry_writer->SetKeyValue(kKey, kValue); 99 entry_writer->SetKeyValue(kKey, kValue);
100 dictionary_writer.AddEntry(crashpad::move(entry_writer)); 100 dictionary_writer.AddEntry(std::move(entry_writer));
101 101
102 EXPECT_TRUE(dictionary_writer.IsUseful()); 102 EXPECT_TRUE(dictionary_writer.IsUseful());
103 103
104 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file)); 104 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file));
105 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) + 105 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) +
106 sizeof(MinidumpSimpleStringDictionaryEntry) + 106 sizeof(MinidumpSimpleStringDictionaryEntry) +
107 2 * sizeof(MinidumpUTF8String) + sizeof(kKey) + sizeof(kValue), 107 2 * sizeof(MinidumpUTF8String) + sizeof(kKey) + sizeof(kValue),
108 string_file.string().size()); 108 string_file.string().size());
109 109
110 const MinidumpSimpleStringDictionary* dictionary = 110 const MinidumpSimpleStringDictionary* dictionary =
(...skipping 17 matching lines...) Expand all
128 char kValue0[] = "value0"; 128 char kValue0[] = "value0";
129 char kKey1[] = "zzz1"; 129 char kKey1[] = "zzz1";
130 char kValue1[] = "v1"; 130 char kValue1[] = "v1";
131 char kKey2[] = "aa2"; 131 char kKey2[] = "aa2";
132 char kValue2[] = "val2"; 132 char kValue2[] = "val2";
133 133
134 MinidumpSimpleStringDictionaryWriter dictionary_writer; 134 MinidumpSimpleStringDictionaryWriter dictionary_writer;
135 auto entry_writer_0 = 135 auto entry_writer_0 =
136 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 136 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
137 entry_writer_0->SetKeyValue(kKey0, kValue0); 137 entry_writer_0->SetKeyValue(kKey0, kValue0);
138 dictionary_writer.AddEntry(crashpad::move(entry_writer_0)); 138 dictionary_writer.AddEntry(std::move(entry_writer_0));
139 auto entry_writer_1 = 139 auto entry_writer_1 =
140 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 140 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
141 entry_writer_1->SetKeyValue(kKey1, kValue1); 141 entry_writer_1->SetKeyValue(kKey1, kValue1);
142 dictionary_writer.AddEntry(crashpad::move(entry_writer_1)); 142 dictionary_writer.AddEntry(std::move(entry_writer_1));
143 auto entry_writer_2 = 143 auto entry_writer_2 =
144 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 144 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
145 entry_writer_2->SetKeyValue(kKey2, kValue2); 145 entry_writer_2->SetKeyValue(kKey2, kValue2);
146 dictionary_writer.AddEntry(crashpad::move(entry_writer_2)); 146 dictionary_writer.AddEntry(std::move(entry_writer_2));
147 147
148 EXPECT_TRUE(dictionary_writer.IsUseful()); 148 EXPECT_TRUE(dictionary_writer.IsUseful());
149 149
150 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file)); 150 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file));
151 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) + 151 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) +
152 3 * sizeof(MinidumpSimpleStringDictionaryEntry) + 152 3 * sizeof(MinidumpSimpleStringDictionaryEntry) +
153 6 * sizeof(MinidumpUTF8String) + sizeof(kKey2) + 153 6 * sizeof(MinidumpUTF8String) + sizeof(kKey2) +
154 sizeof(kValue2) + 3 + sizeof(kKey0) + 1 + sizeof(kValue0) + 1 + 154 sizeof(kValue2) + 3 + sizeof(kKey0) + 1 + sizeof(kValue0) + 1 +
155 sizeof(kKey1) + 3 + sizeof(kValue1), 155 sizeof(kKey1) + 3 + sizeof(kValue1),
156 string_file.string().size()); 156 string_file.string().size());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 StringFile string_file; 196 StringFile string_file;
197 197
198 char kKey[] = "key"; 198 char kKey[] = "key";
199 char kValue0[] = "fake_value"; 199 char kValue0[] = "fake_value";
200 char kValue1[] = "value"; 200 char kValue1[] = "value";
201 201
202 MinidumpSimpleStringDictionaryWriter dictionary_writer; 202 MinidumpSimpleStringDictionaryWriter dictionary_writer;
203 auto entry_writer_0 = 203 auto entry_writer_0 =
204 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 204 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
205 entry_writer_0->SetKeyValue(kKey, kValue0); 205 entry_writer_0->SetKeyValue(kKey, kValue0);
206 dictionary_writer.AddEntry(crashpad::move(entry_writer_0)); 206 dictionary_writer.AddEntry(std::move(entry_writer_0));
207 auto entry_writer_1 = 207 auto entry_writer_1 =
208 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 208 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
209 entry_writer_1->SetKeyValue(kKey, kValue1); 209 entry_writer_1->SetKeyValue(kKey, kValue1);
210 dictionary_writer.AddEntry(crashpad::move(entry_writer_1)); 210 dictionary_writer.AddEntry(std::move(entry_writer_1));
211 211
212 EXPECT_TRUE(dictionary_writer.IsUseful()); 212 EXPECT_TRUE(dictionary_writer.IsUseful());
213 213
214 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file)); 214 EXPECT_TRUE(dictionary_writer.WriteEverything(&string_file));
215 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) + 215 ASSERT_EQ(sizeof(MinidumpSimpleStringDictionary) +
216 sizeof(MinidumpSimpleStringDictionaryEntry) + 216 sizeof(MinidumpSimpleStringDictionaryEntry) +
217 2 * sizeof(MinidumpUTF8String) + sizeof(kKey) + sizeof(kValue1), 217 2 * sizeof(MinidumpUTF8String) + sizeof(kKey) + sizeof(kValue1),
218 string_file.string().size()); 218 string_file.string().size());
219 219
220 const MinidumpSimpleStringDictionary* dictionary = 220 const MinidumpSimpleStringDictionary* dictionary =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 MinidumpUTF8StringAtRVAAsString(string_file.string(), 279 MinidumpUTF8StringAtRVAAsString(string_file.string(),
280 dictionary->entries[2].key)); 280 dictionary->entries[2].key));
281 EXPECT_EQ(kValue2, 281 EXPECT_EQ(kValue2,
282 MinidumpUTF8StringAtRVAAsString(string_file.string(), 282 MinidumpUTF8StringAtRVAAsString(string_file.string(),
283 dictionary->entries[2].value)); 283 dictionary->entries[2].value));
284 } 284 }
285 285
286 } // namespace 286 } // namespace
287 } // namespace test 287 } // namespace test
288 } // 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