Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

more concessions to increase coverage

  • Loading branch information...
commit 9300876abb30e666bcbc957352b36096148a5a4b 1 parent 99d38f9
Christopher League authored September 11, 2009
7  net/contrapunctus/lzma/ApiDriftTest.java
@@ -2,6 +2,7 @@
2 2
 
3 3
 import java.io.ByteArrayInputStream;
4 4
 import java.io.ByteArrayOutputStream;
  5
+import java.io.IOException;
5 6
 import java.io.InputStream;
6 7
 import java.io.OutputStream;
7 8
 import org.junit.Test;
@@ -49,4 +50,10 @@
49 50
         lis = new LzmaInputStream(new ByteArrayInputStream(new byte[0]));
50 51
         assertTrue(lis instanceof InputStream);
51 52
     }
  53
+
  54
+    @Test public void entryPoints() throws IOException
  55
+    {
  56
+        RoundTripTest.main(new String[0]);
  57
+        RoundTripTest.main(new String[] {"build.xml"});
  58
+    }
52 59
 }
31  net/contrapunctus/lzma/LzmaCompatTest.java
@@ -69,35 +69,4 @@ public String toString()
69 69
         System.out.printf("%d bytes, sum %x\n", n, val);
70 70
         assertTrue(file.getName().startsWith(Long.toHexString(val)));
71 71
     }
72  
-
73  
-    public static void writeFile( String name ) throws IOException
74  
-    {
75  
-        System.out.printf("writing %s with%s header\n",
76  
-                          name,
77  
-                          LzmaOutputStream.LZMA_HEADER? "" : " no");
78  
-        FileOutputStream fos = new FileOutputStream( name );
79  
-        LzmaOutputStream lo = new LzmaOutputStream( fos );
80  
-        PrintStream ps = new PrintStream( lo );
81  
-        ps.println("Hello, world -- this is a test!");
82  
-        ps.close(); // is that enough?
83  
-    }
84  
-
85  
-    public static void main( String[] args ) throws IOException
86  
-    {
87  
-        LzmaOutputStream.LZMA_HEADER = true;
88  
-        writeFile("out-true.txt.lzma");
89  
-        LzmaOutputStream.LZMA_HEADER = false;
90  
-        writeFile("out-false.txt.lzma");
91  
-
92  
-        LzmaOutputStream.LZMA_HEADER = true;
93  
-        FileInputStream fis = new FileInputStream( args[0] );
94  
-        LzmaInputStream li = new LzmaInputStream( fis );
95  
-        InputStreamReader isr = new InputStreamReader( li );
96  
-        BufferedReader br = new BufferedReader( isr );
97  
-        String s;
98  
-        while( null != (s = br.readLine() )) {
99  
-            System.out.println(s);
100  
-        }
101  
-        br.close();
102  
-    }
103 72
 }
41  net/contrapunctus/lzma/LzmaOutputStream.java
@@ -77,45 +77,4 @@ public String toString( )
77 77
     {
78 78
         return String.format("lzmaOut@%x", hashCode());
79 79
     }
80  
-
81  
-    public static void main( String[] args ) throws IOException
82  
-    {
83  
-        String s1 = "Hello hello hello, world!";
84  
-        String s2 = "This is the best test.";        
85  
-        OutputStream os = new OutputStream() {
86  
-                public void write(int i)
87  
-                {
88  
-                    System.out.printf("%02x ", i);
89  
-                }
90  
-            };
91  
-        
92  
-        LzmaOutputStream zo = new LzmaOutputStream( os );
93  
-        PrintStream ps = new PrintStream( zo );
94  
-        ps.print(s1);
95  
-        ps.print(s2);        
96  
-        ps.close( );
97  
-        System.out.println();
98  
-        //////////////////
99  
-        System.out.println("TRADITIONAL WAY:");
100  
-        
101  
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
102  
-        ps = new PrintStream( baos );
103  
-        ps.print(s1);
104  
-        ps.print(s2);
105  
-        ps.close();
106  
-        byte[] buf = baos.toByteArray();
107  
-        ByteArrayInputStream bis = new ByteArrayInputStream( buf );
108  
-        baos = new ByteArrayOutputStream();
109  
-        Encoder enc = new Encoder();
110  
-        enc.SetEndMarkerMode(true);
111  
-        enc.SetDictionarySize( 1 << 20 );
112  
-        enc.WriteCoderProperties( baos );
113  
-        enc.Code( bis, baos, -1, -1, null );
114  
-        buf = baos.toByteArray();
115  
-        for( int i = 0;  i < buf.length;  i++ )
116  
-            {
117  
-                System.out.printf("%02x ", buf[i]);
118  
-            }
119  
-        System.out.println();
120  
-    }
121 80
 }
29  net/contrapunctus/lzma/RoundTripTest.java
@@ -36,29 +36,15 @@
36 36
                 args.add(new Object[] { f, false });
37 37
                 args.add(new Object[] { f, true });
38 38
             }
  39
+        args.add(new Object[] { null, false });
  40
+        args.add(new Object[] { null, true });
39 41
         return args;
40 42
     }
41 43
 
42 44
     String name;
43 45
     byte[] original;
44 46
     boolean header;
45  
-
46  
-    private static final boolean DEBUG;
47  
-    private static final String sample;
48  
-    static {
49  
-        String ds = null;
50  
-        try { ds = System.getProperty("DEBUG_RoundTrip"); }
51  
-        catch(SecurityException e) { }
52  
-        DEBUG = ds != null;
53  
-
54  
-        String s = null;
55  
-        try {
56  
-            s = System.getProperty("RoundTripText"); 
57  
-        }
58  
-        catch(SecurityException e) { }
59  
-        if(s != null) sample = s;
60  
-        else sample = "Yes yes yes test test test.";
61  
-    }
  47
+    boolean DEBUG;
62 48
 
63 49
     public RoundTripTest(File file, boolean header) throws IOException
64 50
     {
@@ -75,8 +61,15 @@ public RoundTripTest(File file, boolean header) throws IOException
75 61
             }
76 62
         else
77 63
             {
  64
+                String s = null;
  65
+                try {
  66
+                    s = System.getProperty("RoundTripText"); 
  67
+                }
  68
+                catch(SecurityException e) { }
  69
+                if(s == null) s = "Yes yes yes test test test.";
78 70
                 this.name = "-";
79  
-                this.original = sample.getBytes();
  71
+                this.original = s.getBytes();
  72
+                this.DEBUG = true;
80 73
             }
81 74
     }
82 75
 

0 notes on commit 9300876

Please sign in to comment.
Something went wrong with that request. Please try again.