Skip to content

Commit

Permalink
test to decode files created with lzma(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
league committed Sep 4, 2009
1 parent 2b849dc commit 60fa2f7
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 2 deletions.
64 changes: 62 additions & 2 deletions net/contrapunctus/lzma/LzmaCompatTest.java
@@ -1,4 +1,4 @@
// LzmaCompat.java -- test program for compatibility with lzma(1) // LzmaCompatTest.java -- test program for compatibility with lzma(1)
// Copyright (c)2009 Christopher League <league@contrapunctus.net> // Copyright (c)2009 Christopher League <league@contrapunctus.net>


// This is free software, but it comes with ABSOLUTELY NO WARRANTY. // This is free software, but it comes with ABSOLUTELY NO WARRANTY.
Expand All @@ -7,9 +7,69 @@
package net.contrapunctus.lzma; package net.contrapunctus.lzma;


import java.io.*; import java.io.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.zip.CRC32;
import java.util.zip.CheckedInputStream;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertTrue;


public class LzmaCompat @RunWith(Parameterized.class)
public class LzmaCompatTest
{ {
@Parameters public static Collection<Object[]> parameters()
throws FileNotFoundException
{
File dir = new File("tests/lzma-cmd");
File[] fs = dir.listFiles();
if(null == fs)
{
throw new FileNotFoundException
("directory tests/lzma-cmd not found");
}
Collection<Object[]> args = new ArrayList<Object[]>();
for(File f : fs)
{
args.add(new Object[] { f });
}
return args;
}

File file;

public LzmaCompatTest(File file)
{
this.file = file;
}

public String toString()
{
return file.toString();
}

@Test public void decode()
throws IOException
{
System.out.printf("%s:", this);
FileInputStream fis = new FileInputStream(file);
LzmaInputStream lis = new LzmaInputStream(fis);
CRC32 sum = new CRC32();
CheckedInputStream cis = new CheckedInputStream(lis, sum);
byte[] buf = new byte[4096];
int k, n = 0;
while( -1 != (k = cis.read(buf)))
{
n += k;
}
cis.close();
long val = sum.getValue();
System.out.printf("%d bytes, sum %x\n", n, val);
assertTrue(file.getName().startsWith(Long.toHexString(val)));
}

public static void writeFile( String name ) throws IOException public static void writeFile( String name ) throws IOException
{ {
System.out.printf("writing %s with%s header\n", System.out.printf("writing %s with%s header\n",
Expand Down
Binary file added tests/lzma-cmd/f3d7485d.1.lzma
Binary file not shown.
Binary file added tests/lzma-cmd/f3d7485d.2.lzma
Binary file not shown.
Binary file added tests/lzma-cmd/f3d7485d.3.lzma
Binary file not shown.
Binary file added tests/lzma-cmd/f3d7485d.4.lzma
Binary file not shown.
Binary file added tests/lzma-cmd/f3d7485d.5.lzma
Binary file not shown.
Binary file added tests/lzma-cmd/f3d7485d.6.lzma
Binary file not shown.
Binary file added tests/lzma-cmd/f3d7485d.7.lzma
Binary file not shown.
Binary file added tests/lzma-cmd/f3d7485d.8.lzma
Binary file not shown.
Binary file added tests/lzma-cmd/f3d7485d.9.lzma
Binary file not shown.

0 comments on commit 60fa2f7

Please sign in to comment.