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

Side by Side Diff: courgette/disassembler_win32_x86_unittest.cc

Issue 1855133002: convert //courgette to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment in memory_allocator.h Created 4 years, 8 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 | « courgette/disassembler_win32_x64_unittest.cc ('k') | courgette/encode_decode_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "courgette/disassembler_win32_x86.h" 5 #include "courgette/disassembler_win32_x86.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/memory/scoped_ptr.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "courgette/base_test_unittest.h" 14 #include "courgette/base_test_unittest.h"
15 15
16 class DisassemblerWin32X86Test : public BaseTest { 16 class DisassemblerWin32X86Test : public BaseTest {
17 public: 17 public:
18 void TestExe() const; 18 void TestExe() const;
19 void TestExe64() const; 19 void TestExe64() const;
20 void TestResourceDll() const; 20 void TestResourceDll() const;
21 }; 21 };
22 22
23 void DisassemblerWin32X86Test::TestExe() const { 23 void DisassemblerWin32X86Test::TestExe() const {
24 std::string file1 = FileContents("setup1.exe"); 24 std::string file1 = FileContents("setup1.exe");
25 25
26 scoped_ptr<courgette::DisassemblerWin32X86> disassembler( 26 std::unique_ptr<courgette::DisassemblerWin32X86> disassembler(
27 new courgette::DisassemblerWin32X86(file1.c_str(), file1.length())); 27 new courgette::DisassemblerWin32X86(file1.c_str(), file1.length()));
28 28
29 bool can_parse_header = disassembler->ParseHeader(); 29 bool can_parse_header = disassembler->ParseHeader();
30 EXPECT_TRUE(can_parse_header); 30 EXPECT_TRUE(can_parse_header);
31 31
32 // The executable is the whole file, not 'embedded' with the file 32 // The executable is the whole file, not 'embedded' with the file
33 EXPECT_EQ(file1.length(), disassembler->length()); 33 EXPECT_EQ(file1.length(), disassembler->length());
34 34
35 EXPECT_TRUE(disassembler->ok()); 35 EXPECT_TRUE(disassembler->ok());
36 EXPECT_TRUE(disassembler->has_text_section()); 36 EXPECT_TRUE(disassembler->has_text_section());
(...skipping 21 matching lines...) Expand all
58 const uint8_t* rva_p = disassembler->RVAToPointer(0); 58 const uint8_t* rva_p = disassembler->RVAToPointer(0);
59 EXPECT_EQ(reinterpret_cast<const void*>(file1.c_str()), 59 EXPECT_EQ(reinterpret_cast<const void*>(file1.c_str()),
60 reinterpret_cast<const void*>(rva_p)); 60 reinterpret_cast<const void*>(rva_p));
61 EXPECT_EQ('M', rva_p[0]); 61 EXPECT_EQ('M', rva_p[0]);
62 EXPECT_EQ('Z', rva_p[1]); 62 EXPECT_EQ('Z', rva_p[1]);
63 } 63 }
64 64
65 void DisassemblerWin32X86Test::TestExe64() const { 65 void DisassemblerWin32X86Test::TestExe64() const {
66 std::string file1 = FileContents("pe-64.exe"); 66 std::string file1 = FileContents("pe-64.exe");
67 67
68 scoped_ptr<courgette::DisassemblerWin32X86> disassembler( 68 std::unique_ptr<courgette::DisassemblerWin32X86> disassembler(
69 new courgette::DisassemblerWin32X86(file1.c_str(), file1.length())); 69 new courgette::DisassemblerWin32X86(file1.c_str(), file1.length()));
70 70
71 bool can_parse_header = disassembler->ParseHeader(); 71 bool can_parse_header = disassembler->ParseHeader();
72 EXPECT_FALSE(can_parse_header); 72 EXPECT_FALSE(can_parse_header);
73 73
74 // The executable is the whole file, not 'embedded' with the file 74 // The executable is the whole file, not 'embedded' with the file
75 EXPECT_EQ(file1.length(), disassembler->length()); 75 EXPECT_EQ(file1.length(), disassembler->length());
76 76
77 EXPECT_FALSE(disassembler->ok()); 77 EXPECT_FALSE(disassembler->ok());
78 EXPECT_TRUE(disassembler->has_text_section()); 78 EXPECT_TRUE(disassembler->has_text_section());
79 EXPECT_EQ(43008U, disassembler->size_of_code()); 79 EXPECT_EQ(43008U, disassembler->size_of_code());
80 EXPECT_FALSE(disassembler->is_32bit()); 80 EXPECT_FALSE(disassembler->is_32bit());
81 } 81 }
82 82
83 void DisassemblerWin32X86Test::TestResourceDll() const { 83 void DisassemblerWin32X86Test::TestResourceDll() const {
84 std::string file1 = FileContents("en-US.dll"); 84 std::string file1 = FileContents("en-US.dll");
85 85
86 scoped_ptr<courgette::DisassemblerWin32X86> disassembler( 86 std::unique_ptr<courgette::DisassemblerWin32X86> disassembler(
87 new courgette::DisassemblerWin32X86(file1.c_str(), file1.length())); 87 new courgette::DisassemblerWin32X86(file1.c_str(), file1.length()));
88 88
89 bool can_parse_header = disassembler->ParseHeader(); 89 bool can_parse_header = disassembler->ParseHeader();
90 EXPECT_FALSE(can_parse_header); 90 EXPECT_FALSE(can_parse_header);
91 91
92 // The executable is the whole file, not 'embedded' with the file 92 // The executable is the whole file, not 'embedded' with the file
93 EXPECT_EQ(file1.length(), disassembler->length()); 93 EXPECT_EQ(file1.length(), disassembler->length());
94 94
95 EXPECT_FALSE(disassembler->ok()); 95 EXPECT_FALSE(disassembler->ok());
96 EXPECT_FALSE(disassembler->has_text_section()); 96 EXPECT_FALSE(disassembler->has_text_section());
97 EXPECT_EQ(0U, disassembler->size_of_code()); 97 EXPECT_EQ(0U, disassembler->size_of_code());
98 EXPECT_TRUE(disassembler->is_32bit()); 98 EXPECT_TRUE(disassembler->is_32bit());
99 } 99 }
100 100
101 TEST_F(DisassemblerWin32X86Test, All) { 101 TEST_F(DisassemblerWin32X86Test, All) {
102 TestExe(); 102 TestExe();
103 TestExe64(); 103 TestExe64();
104 TestResourceDll(); 104 TestResourceDll();
105 } 105 }
OLDNEW
« no previous file with comments | « courgette/disassembler_win32_x64_unittest.cc ('k') | courgette/encode_decode_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698