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

Unified Diff: courgette/versioning_unittest.cc

Issue 8252011: Add a basic backwards compatibility unittest. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix review nits. 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 side-by-side diff with in-line comments
Download patch
« courgette/base_test_unittest.cc ('K') | « courgette/image_info_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/versioning_unittest.cc
diff --git a/courgette/versioning_unittest.cc b/courgette/versioning_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8e2bdfe9e4ffd3a72e57285b95bf6e82c351c621
--- /dev/null
+++ b/courgette/versioning_unittest.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "courgette/base_test_unittest.h"
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "courgette/courgette.h"
+#include "courgette/streams.h"
+
+class VersioningTest : public BaseTest {
+ public:
+ void TestApplyingOldPatch(const char* src_file,
+ const char* patch_file,
Paweł Hajdan Jr. 2011/10/19 08:46:39 nit: Indentation is off.
+ const char* expected_file) const;
+};
+
+void VersioningTest::TestApplyingOldPatch(const char* src_file,
+ const char* patch_file,
+ const char* expected_file) const {
+
Paweł Hajdan Jr. 2011/10/19 08:46:39 nit: Remove empty line.
+ std::string old_buffer = FileContents(src_file);
+ std::string new_buffer = FileContents(patch_file);
+ std::string expected_buffer = FileContents(expected_file);
+
+ courgette::SourceStream old_stream;
+ courgette::SourceStream patch_stream;
+ old_stream.Init(old_buffer);
+ patch_stream.Init(new_buffer);
+
+ courgette::SinkStream generated_stream;
+
+ courgette::Status status =
+ courgette::ApplyEnsemblePatch(&old_stream,
+ &patch_stream,
+ &generated_stream);
+
+ EXPECT_EQ(status, courgette::C_OK);
+
+ size_t expected_length = expected_buffer.size();
+ size_t generated_length = generated_stream.Length();
+
+ EXPECT_EQ(generated_length, expected_length);
+ EXPECT_EQ(0, memcmp(generated_stream.Buffer(),
+ expected_buffer.c_str(),
+ expected_length));
+}
+
+
+TEST_F(VersioningTest, All) {
+ TestApplyingOldPatch("setup1.exe", "setup1-setup2.v1.patch", "setup2.exe");
+
+ // We also need a way to test that newly generated patches are appropriately
+ // applicable by older clients... not sure of the best way to do that.
+}
« courgette/base_test_unittest.cc ('K') | « courgette/image_info_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698