/*-
 * Copyright (c) 2014 Mikolaj Izdebski
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.lbzip2;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;

import org.junit.Test;

/**
 * @author Mikolaj Izdebski
 */
public class LBzip2OutputStreamTest
{
    /**
     * Regression test for bug nr 1.
     * <p>
     * See: https://github.com/kjn/lbzip2-java/issues/1
     * 
     * @throws Exception
     */
    @Test
    public void testBug1()
        throws Exception
    {
        OutputStream os = new LBzip2OutputStream( new ByteArrayOutputStream(), 900000 );
        os.write( 'c' );
        os.close();
    }
}

@@ -619,16 +619,62 @@
 bzip2;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0A
 import j
@@ -831,16 +831,650 @@
 mTest%0A%7B%0A
+    /**%0A     * Test compression of empty file.%0A     * %0A     * @throws Exception%0A     */%0A    @Test%0A    public void testEmptyStream()%0A        throws Exception%0A    %7B%0A        ByteArrayOutputStream os = new ByteArrayOutputStream();%0A        new LBzip2OutputStream( os, 42 ).close();%0A        byte%5B%5D out = os.toByteArray();%0A%0A        byte%5B%5D exp =%0A            new byte%5B%5D %7B 0x42, 0x5a, 0x68, 0x31, 0x17, 0x72, 0x45, 0x38, 0x50, (byte) 0x90, 0x00, 0x00, 0x00, 0x00 %7D;%0A%0A        assertEquals( exp.length, out.length );%0A%0A        for ( int i = 0; i %3C exp.length; i++ )%0A        %7B%0A            assertEquals( %22i=%22 + i, exp%5Bi%5D, out%5Bi%5D );%0A        %7D%0A    %7D%0A%0A
     /**%0A

Implement LBzip2OutputStreamTest.testEmptyStream()