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

Unified Diff: courgette/bsdiff_memory_unittest.cc

Issue 2228003: Use an array of pages for the large arrays.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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
« no previous file with comments | « no previous file | courgette/courgette.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/bsdiff_memory_unittest.cc
===================================================================
--- courgette/bsdiff_memory_unittest.cc (revision 48525)
+++ courgette/bsdiff_memory_unittest.cc (working copy)
@@ -20,6 +20,8 @@
std::string FileContents(const char* file_name) const;
void GenerateAndTestPatch(const std::string& a, const std::string& b) const;
+ std::string GenerateSyntheticInput(size_t length, int seed) const;
+
private:
void SetUp() {
PathService::Get(base::DIR_SOURCE_ROOT, &test_dir_);
@@ -64,6 +66,18 @@
EXPECT_EQ(0, memcmp(new_text.c_str(), new2.Buffer(), new_text.length()));
}
+std::string BSDiffMemoryTest::GenerateSyntheticInput(size_t length, int seed)
+ const {
+ static const char* a[8] = {"O", "A", "x", "-", "y", ".", "|", ":"};
+ std::string result;
+ while (result.length() < length) {
+ seed = (seed + 17) * 1049 + (seed >> 27);
+ result.append(a[seed & 7]);
+ }
+ result.resize(length);
+ return result;
+}
+
TEST_F(BSDiffMemoryTest, TestEmpty) {
GenerateAndTestPatch("", "");
}
@@ -99,6 +113,28 @@
GenerateAndTestPatch(file1, file2);
}
+TEST_F(BSDiffMemoryTest, TestNearPageArrayPageSize) {
+ // This magic number is the size of one block of the PageArray in
+ // third_party/bsdiff_create.cc.
+ size_t critical_size = 1 << 18;
+
+ // Test first-inputs with sizes that straddle the magic size to test this
+ // PageArray's internal boundary condition.
+
+ std::string file1 = GenerateSyntheticInput(critical_size, 0);
+ std::string file2 = GenerateSyntheticInput(critical_size, 1);
+ GenerateAndTestPatch(file1, file2);
+
+ std::string file1a = file1.substr(0, critical_size - 1);
+ GenerateAndTestPatch(file1a, file2);
+
+ std::string file1b = file1.substr(0, critical_size - 2);
+ GenerateAndTestPatch(file1b, file2);
+
+ std::string file1c = file1 + file1.substr(0, 1);
+ GenerateAndTestPatch(file1c, file2);
+}
+
TEST_F(BSDiffMemoryTest, TestIndenticalDlls) {
std::string file1 = FileContents("en-US.dll");
GenerateAndTestPatch(file1, file1);
« no previous file with comments | « no previous file | courgette/courgette.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698