Permalink
Browse files

Added random test of large blobs.

  • Loading branch information...
1 parent a81c8f3 commit 4b434e26b4cbfda52e282640f78bdbcaebe5f07a @esstrifork esstrifork committed Jun 23, 2011
Showing with 26 additions and 6 deletions.
  1. +26 −6 src/test/java/com/trifork/deltazip/DeltaZipTest.java
@@ -113,15 +113,32 @@ public void test_add_get_with(byte[] file0, ByteBuffer rev1, ByteBuffer rev2) th
@Test
public void totally_random_test() throws IOException {
final Random rnd = new Random();
- byte[] file = new byte[0];
- // Create versions:
- ByteBuffer[] versions = new ByteBuffer[100];
- for (int i=0; i<versions.length; i++)
- versions[i] = createRandomBinary(1000, rnd);
+ { // 100 x 1K.
+ ByteBuffer[] versions = new ByteBuffer[100];
+ for (int i=0; i<versions.length; i++)
+ versions[i] = createRandomBinary(1000, rnd);
+
+ series_test_with(versions);
+ }
+
+ { // 40 x 100K.
+ ByteBuffer[] versions = new ByteBuffer[40];
+ for (int i=0; i<versions.length; i++)
+ versions[i] = createRandomBinary(100000, rnd);
+
+ series_test_with(versions);
+ }
+ }
+
+ public void series_test_with(ByteBuffer[] versions) throws IOException {
+ byte[] file = new byte[0];
+
+ System.err.print("<");
// Add versions:
- for (int i=0; i<100; i++) {
+ for (int i=0; i<versions.length; i++) {
+ System.err.print(".");
ByteArrayAccess access = new ByteArrayAccess(file);
DeltaZip dz = new DeltaZip(access);
AppendSpecification app_spec =
@@ -133,6 +150,7 @@ public void totally_random_test() throws IOException {
ByteArrayAccess access = new ByteArrayAccess(file);
DeltaZip dz = new DeltaZip(access);
for (int i=versions.length-1; i>=0; i--) {
+ System.err.print(",");
assertEquals(dz.get(), versions[i]);
if (i>0) {
assert(dz.hasPrevious());
@@ -141,6 +159,8 @@ public void totally_random_test() throws IOException {
}
assert(! dz.hasPrevious());
}
+ System.err.println(">");
+
}
//======================================================================

0 comments on commit 4b434e2

Please sign in to comment.