| OLD | NEW |
| 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 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "courgette/courgette.h" | 10 #include "courgette/courgette.h" |
| 11 #include "courgette/streams.h" | 11 #include "courgette/streams.h" |
| 12 | 12 |
| 13 class VersioningTest : public BaseTest { | 13 class VersioningTest : public BaseTest { |
| 14 public: | 14 public: |
| 15 void TestApplyingOldPatch(const char* src_file, | 15 void TestApplyingOldPatch(const char* src_file, |
| 16 const char* patch_file, | 16 const char* patch_file, |
| 17 const char* expected_file) const; | 17 const char* expected_file) const; |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 void VersioningTest::TestApplyingOldPatch(const char* src_file, | 20 void VersioningTest::TestApplyingOldPatch(const char* src_file, |
| 21 const char* patch_file, | 21 const char* patch_file, |
| 22 const char* expected_file) const { | 22 const char* expected_file) const { |
| 23 | |
| 24 std::string old_buffer = FileContents(src_file); | 23 std::string old_buffer = FileContents(src_file); |
| 25 std::string new_buffer = FileContents(patch_file); | 24 std::string new_buffer = FileContents(patch_file); |
| 26 std::string expected_buffer = FileContents(expected_file); | 25 std::string expected_buffer = FileContents(expected_file); |
| 27 | 26 |
| 28 courgette::SourceStream old_stream; | 27 courgette::SourceStream old_stream; |
| 29 courgette::SourceStream patch_stream; | 28 courgette::SourceStream patch_stream; |
| 30 old_stream.Init(old_buffer); | 29 old_stream.Init(old_buffer); |
| 31 patch_stream.Init(new_buffer); | 30 patch_stream.Init(new_buffer); |
| 32 | 31 |
| 33 courgette::SinkStream generated_stream; | 32 courgette::SinkStream generated_stream; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 48 expected_length)); | 47 expected_length)); |
| 49 } | 48 } |
| 50 | 49 |
| 51 | 50 |
| 52 TEST_F(VersioningTest, All) { | 51 TEST_F(VersioningTest, All) { |
| 53 TestApplyingOldPatch("setup1.exe", "setup1-setup2.v1.patch", "setup2.exe"); | 52 TestApplyingOldPatch("setup1.exe", "setup1-setup2.v1.patch", "setup2.exe"); |
| 54 | 53 |
| 55 // We also need a way to test that newly generated patches are appropriately | 54 // We also need a way to test that newly generated patches are appropriately |
| 56 // applicable by older clients... not sure of the best way to do that. | 55 // applicable by older clients... not sure of the best way to do that. |
| 57 } | 56 } |
| OLD | NEW |