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

Side by Side Diff: minidump/minidump_string_writer_test_util.cc

Issue 654573003: Add MinidumpCrashpadInfoWriter and its test (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 unified diff | Download patch
« no previous file with comments | « minidump/minidump_string_writer_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "minidump/minidump_string_writer_test_util.h"
16
17 #include "gtest/gtest.h"
18 #include "minidump/minidump_extensions.h"
19
20 namespace crashpad {
21 namespace test {
22
23 std::string MinidumpUTF8StringAtRVA(const StringFileWriter& file_writer,
24 RVA rva) {
25 const std::string& contents = file_writer.string();
26 if (rva == 0) {
27 return std::string();
28 }
29
30 if (rva + sizeof(MinidumpUTF8String) > contents.size()) {
31 ADD_FAILURE()
32 << "rva " << rva << " too large for contents " << contents.size();
33 return std::string();
34 }
35
36 const MinidumpUTF8String* minidump_string =
37 reinterpret_cast<const MinidumpUTF8String*>(&contents[rva]);
38
39 // Verify that the file has enough data for the string’s stated length plus
40 // its required NUL terminator.
41 if (rva + sizeof(MinidumpUTF8String) + minidump_string->Length + 1 >
42 contents.size()) {
43 ADD_FAILURE()
44 << "rva " << rva << ", length " << minidump_string->Length
45 << " too large for contents " << contents.size();
46 return std::string();
47 }
48
49 std::string minidump_string_data(
50 reinterpret_cast<const char*>(&minidump_string->Buffer[0]),
51 minidump_string->Length);
52 return minidump_string_data;
53 }
54
55 } // namespace test
56 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_string_writer_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698