Permalink
Browse files

more concessions to increase coverage

  • Loading branch information...
1 parent 99d38f9 commit 9300876abb30e666bcbc957352b36096148a5a4b @league committed Sep 11, 2009
@@ -2,6 +2,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.junit.Test;
@@ -49,4 +50,10 @@
lis = new LzmaInputStream(new ByteArrayInputStream(new byte[0]));
assertTrue(lis instanceof InputStream);
}
+
+ @Test public void entryPoints() throws IOException
+ {
+ RoundTripTest.main(new String[0]);
+ RoundTripTest.main(new String[] {"build.xml"});
+ }
}
@@ -69,35 +69,4 @@ public String toString()
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
- {
- System.out.printf("writing %s with%s header\n",
- name,
- LzmaOutputStream.LZMA_HEADER? "" : " no");
- FileOutputStream fos = new FileOutputStream( name );
- LzmaOutputStream lo = new LzmaOutputStream( fos );
- PrintStream ps = new PrintStream( lo );
- ps.println("Hello, world -- this is a test!");
- ps.close(); // is that enough?
- }
-
- public static void main( String[] args ) throws IOException
- {
- LzmaOutputStream.LZMA_HEADER = true;
- writeFile("out-true.txt.lzma");
- LzmaOutputStream.LZMA_HEADER = false;
- writeFile("out-false.txt.lzma");
-
- LzmaOutputStream.LZMA_HEADER = true;
- FileInputStream fis = new FileInputStream( args[0] );
- LzmaInputStream li = new LzmaInputStream( fis );
- InputStreamReader isr = new InputStreamReader( li );
- BufferedReader br = new BufferedReader( isr );
- String s;
- while( null != (s = br.readLine() )) {
- System.out.println(s);
- }
- br.close();
- }
}
@@ -77,45 +77,4 @@ public String toString( )
{
return String.format("lzmaOut@%x", hashCode());
}
-
- public static void main( String[] args ) throws IOException
- {
- String s1 = "Hello hello hello, world!";
- String s2 = "This is the best test.";
- OutputStream os = new OutputStream() {
- public void write(int i)
- {
- System.out.printf("%02x ", i);
- }
- };
-
- LzmaOutputStream zo = new LzmaOutputStream( os );
- PrintStream ps = new PrintStream( zo );
- ps.print(s1);
- ps.print(s2);
- ps.close( );
- System.out.println();
- //////////////////
- System.out.println("TRADITIONAL WAY:");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ps = new PrintStream( baos );
- ps.print(s1);
- ps.print(s2);
- ps.close();
- byte[] buf = baos.toByteArray();
- ByteArrayInputStream bis = new ByteArrayInputStream( buf );
- baos = new ByteArrayOutputStream();
- Encoder enc = new Encoder();
- enc.SetEndMarkerMode(true);
- enc.SetDictionarySize( 1 << 20 );
- enc.WriteCoderProperties( baos );
- enc.Code( bis, baos, -1, -1, null );
- buf = baos.toByteArray();
- for( int i = 0; i < buf.length; i++ )
- {
- System.out.printf("%02x ", buf[i]);
- }
- System.out.println();
- }
}
@@ -36,29 +36,15 @@
args.add(new Object[] { f, false });
args.add(new Object[] { f, true });
}
+ args.add(new Object[] { null, false });
+ args.add(new Object[] { null, true });
return args;
}
String name;
byte[] original;
boolean header;
-
- private static final boolean DEBUG;
- private static final String sample;
- static {
- String ds = null;
- try { ds = System.getProperty("DEBUG_RoundTrip"); }
- catch(SecurityException e) { }
- DEBUG = ds != null;
-
- String s = null;
- try {
- s = System.getProperty("RoundTripText");
- }
- catch(SecurityException e) { }
- if(s != null) sample = s;
- else sample = "Yes yes yes test test test.";
- }
+ boolean DEBUG;
public RoundTripTest(File file, boolean header) throws IOException
{
@@ -75,8 +61,15 @@ public RoundTripTest(File file, boolean header) throws IOException
}
else
{
+ String s = null;
+ try {
+ s = System.getProperty("RoundTripText");
+ }
+ catch(SecurityException e) { }
+ if(s == null) s = "Yes yes yes test test test.";
this.name = "-";
- this.original = sample.getBytes();
+ this.original = s.getBytes();
+ this.DEBUG = true;
}
}

0 comments on commit 9300876

Please sign in to comment.