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

Side by Side Diff: courgette/encode_decode_unittest.cc

Issue 8344037: Start refactoring to reduce executable type knowledge. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix comment. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « courgette/disassembler_win32_x86.cc ('k') | courgette/encoded_program_fuzz_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/base_test_unittest.h" 5 #include "courgette/base_test_unittest.h"
6 #include "courgette/courgette.h" 6 #include "courgette/courgette.h"
7 #include "courgette/streams.h" 7 #include "courgette/streams.h"
8 8
9 class EncodeDecodeTest : public BaseTest { 9 class EncodeDecodeTest : public BaseTest {
10 public: 10 public:
11 void TestExe(const char *) const; 11 void TestExe(const char *) const;
12 }; 12 };
13 13
14 void EncodeDecodeTest::TestExe(const char* file_name) const { 14 void EncodeDecodeTest::TestExe(const char* file_name) const {
15 // Test top-level Courgette API for converting an a file to a binary 15 // Test top-level Courgette API for converting an a file to a binary
16 // assembly representation and back. 16 // assembly representation and back.
17 std::string file1 = FileContents(file_name); 17 std::string file1 = FileContents(file_name);
18 18
19 const void* original_buffer = file1.c_str(); 19 const void* original_buffer = file1.c_str();
20 size_t original_length = file1.size(); 20 size_t original_length = file1.size();
21 21
22 courgette::AssemblyProgram* program = NULL; 22 courgette::AssemblyProgram* program = NULL;
23 const courgette::Status parse_status = 23 const courgette::Status parse_status =
24 courgette::ParseWin32X86PE(original_buffer, original_length, &program); 24 courgette::ParseDetectedExecutable(original_buffer, original_length,
25 &program);
25 EXPECT_EQ(courgette::C_OK, parse_status); 26 EXPECT_EQ(courgette::C_OK, parse_status);
26 27
27 courgette::EncodedProgram* encoded = NULL; 28 courgette::EncodedProgram* encoded = NULL;
28 29
29 const courgette::Status encode_status = Encode(program, &encoded); 30 const courgette::Status encode_status = Encode(program, &encoded);
30 EXPECT_EQ(courgette::C_OK, encode_status); 31 EXPECT_EQ(courgette::C_OK, encode_status);
31 32
32 DeleteAssemblyProgram(program); 33 DeleteAssemblyProgram(program);
33 34
34 courgette::SinkStreamSet sinks; 35 courgette::SinkStreamSet sinks;
(...skipping 29 matching lines...) Expand all
64 EXPECT_EQ(original_length, assembled_length); 65 EXPECT_EQ(original_length, assembled_length);
65 EXPECT_EQ(0, memcmp(original_buffer, assembled_buffer, original_length)); 66 EXPECT_EQ(0, memcmp(original_buffer, assembled_buffer, original_length));
66 67
67 DeleteEncodedProgram(encoded2); 68 DeleteEncodedProgram(encoded2);
68 } 69 }
69 70
70 71
71 TEST_F(EncodeDecodeTest, All) { 72 TEST_F(EncodeDecodeTest, All) {
72 TestExe("setup1.exe"); 73 TestExe("setup1.exe");
73 } 74 }
OLDNEW
« no previous file with comments | « courgette/disassembler_win32_x86.cc ('k') | courgette/encoded_program_fuzz_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698