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

Side by Side Diff: minidump/minidump_context_writer_test.cc

Issue 628153004: Add MinidumpContextWriter test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Don’t use using directives (“using namespace”) in tests 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_context_test_util.cc ('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_context_writer.h"
16
17 #include <stdint.h>
18
19 #include "gtest/gtest.h"
20 #include "minidump/minidump_context.h"
21 #include "minidump/minidump_context_test_util.h"
22 #include "util/file/string_file_writer.h"
23
24 namespace crashpad {
25 namespace test {
26 namespace {
27
28 TEST(MinidumpContextWriter, MinidumpContextX86Writer) {
29 StringFileWriter file_writer;
30
31 {
32 // Make sure that a context writer that’s untouched writes a zeroed-out
33 // context.
34 SCOPED_TRACE("zero");
35
36 MinidumpContextX86Writer context_writer;
37
38 EXPECT_TRUE(context_writer.WriteEverything(&file_writer));
39 ASSERT_EQ(sizeof(MinidumpContextX86), file_writer.string().size());
40
41 const MinidumpContextX86* observed =
42 reinterpret_cast<const MinidumpContextX86*>(&file_writer.string()[0]);
43 ExpectMinidumpContextX86(0, observed);
44 }
45
46 {
47 SCOPED_TRACE("nonzero");
48
49 file_writer.Reset();
50 const uint32_t kSeed = 0x8086;
51
52 MinidumpContextX86Writer context_writer;
53 InitializeMinidumpContextX86(context_writer.context(), kSeed);
54
55 EXPECT_TRUE(context_writer.WriteEverything(&file_writer));
56 ASSERT_EQ(sizeof(MinidumpContextX86), file_writer.string().size());
57
58 const MinidumpContextX86* observed =
59 reinterpret_cast<const MinidumpContextX86*>(&file_writer.string()[0]);
60 ExpectMinidumpContextX86(kSeed, observed);
61 }
62 }
63
64 TEST(MinidumpContextWriter, MinidumpContextAMD64Writer) {
65 StringFileWriter file_writer;
66
67 {
68 // Make sure that a context writer that’s untouched writes a zeroed-out
69 // context.
70 SCOPED_TRACE("zero");
71
72 MinidumpContextAMD64Writer context_writer;
73
74 EXPECT_TRUE(context_writer.WriteEverything(&file_writer));
75 ASSERT_EQ(sizeof(MinidumpContextAMD64), file_writer.string().size());
76
77 const MinidumpContextAMD64* observed =
78 reinterpret_cast<const MinidumpContextAMD64*>(&file_writer.string()[0]);
79 ExpectMinidumpContextAMD64(0, observed);
80 }
81
82 {
83 SCOPED_TRACE("nonzero");
84
85 file_writer.Reset();
86 const uint32_t kSeed = 0x808664;
87
88 MinidumpContextAMD64Writer context_writer;
89 InitializeMinidumpContextAMD64(context_writer.context(), kSeed);
90
91 EXPECT_TRUE(context_writer.WriteEverything(&file_writer));
92 ASSERT_EQ(sizeof(MinidumpContextAMD64), file_writer.string().size());
93
94 const MinidumpContextAMD64* observed =
95 reinterpret_cast<const MinidumpContextAMD64*>(&file_writer.string()[0]);
96 ExpectMinidumpContextAMD64(kSeed, observed);
97 }
98 }
99
100 } // namespace
101 } // namespace test
102 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_context_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698