Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Add tests from Diffblue Deeptest #233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package info.ata4.disunity.cli.util;

import com.diffblue.deeptestutils.Reflector;
import info.ata4.disunity.cli.OutputFormat;
import info.ata4.disunity.cli.util.JsonTablePrinter;
import info.ata4.disunity.cli.util.TablePrinter;
import info.ata4.disunity.cli.util.TextTablePrinter;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Path;

public class TablePrinterTest {

@Rule public ExpectedException thrown = ExpectedException.none();

/* testedClasses: TablePrinter */

/*
* Test generated by Diffblue Deeptest.
* This test case covers the entire method.
*/

@Test
public void fromOutputFormatInputNotNullNullOutputNotNull() {

// Arrange
final OutputFormat format = OutputFormat.TEXT;
final PrintWriter out = null;

// Act
final TablePrinter retval = TablePrinter.fromOutputFormat(format, out);

// Assert result
Assert.assertNotNull(retval);
Assert.assertNull(((TextTablePrinter)retval).file);
Assert.assertNull(((TextTablePrinter)retval).out);
Assert.assertEquals('=', Reflector.getInstanceField(retval, "nameSeparator"));
Assert.assertEquals('-', Reflector.getInstanceField(retval, "rowSeparator"));
Assert.assertEquals(" ", Reflector.getInstanceField(retval, "cellSeparator"));
}


/*
* Test generated by Diffblue Deeptest.
* This test case covers:
* - case 1 of switch on line 24
*/

@Test
public void fromOutputFormatInputNotNullNullOutputNotNull2() {

// Arrange
final OutputFormat format = OutputFormat.JSON;
final PrintWriter out = null;

// Act
final TablePrinter retval = TablePrinter.fromOutputFormat(format, out);

// Assert result
Assert.assertNotNull(retval);
Assert.assertNull(((JsonTablePrinter)retval).out);
Assert.assertNull(((JsonTablePrinter)retval).file);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
package info.ata4.util.lz4;

import static org.mockito.AdditionalMatchers.or;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.isA;
import static org.mockito.Matchers.isNull;
import static org.powermock.api.mockito.PowerMockito.mockStatic;

import com.diffblue.deeptestutils.Reflector;
import info.ata4.util.lz4.LZ4JavaSafeFastDecompressor;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

@RunWith(PowerMockRunner.class)
public class LZ4JavaSafeFastDecompressorTest {

@Rule public ExpectedException thrown = ExpectedException.none();

/* testedClasses: LZ4JavaSafeFastDecompressor */

/*
* Test generated by Diffblue Deeptest.
* This test case covers:
* - conditional line 23 branch to line 23
*/

@Test
public void decompressInput1Negative1PositivePositiveOutputArrayIndexOutOfBoundsException() {

// Arrange
final LZ4JavaSafeFastDecompressor objectUnderTest = new LZ4JavaSafeFastDecompressor();
final byte[] src = {(byte)-1};
final int srcOff = -1;
final byte[] dest = {(byte)0};
final int destOff = 1_073_744_881;
final int destLen = 270;

// Act
thrown.expect(ArrayIndexOutOfBoundsException.class);
objectUnderTest.decompress(src, srcOff, dest, destOff, destLen);

// Method is not expected to return due to exception thrown
}

/*
* Test generated by Diffblue Deeptest.
* This test case covers:
* - conditional line 23 branch to line 24
* - conditional line 24 branch to line 24
*/

@Test
public void decompressInput1Zero1NegativePositiveOutputArrayIndexOutOfBoundsException() {

// Arrange
final LZ4JavaSafeFastDecompressor objectUnderTest = new LZ4JavaSafeFastDecompressor();
final byte[] src = {(byte)-16};
final int srcOff = 0;
final byte[] dest = {(byte)0};
final int destOff = -2_147_481_363;
final int destLen = 15;

// Act
thrown.expect(ArrayIndexOutOfBoundsException.class);
objectUnderTest.decompress(src, srcOff, dest, destOff, destLen);

// Method is not expected to return due to exception thrown
}

/*
* Test generated by Diffblue Deeptest.
* This test case covers:
* - conditional line 23 branch to line 24
* - conditional line 24 branch to line 26
* - conditional line 26 branch to line 27
* - conditional line 27 branch to line 28
*/

@Test
public void decompressInput1Zero1PositiveZeroOutputLZ4Exception() {

// Arrange
final LZ4JavaSafeFastDecompressor objectUnderTest = new LZ4JavaSafeFastDecompressor();
final byte[] src = {(byte)69};
final int srcOff = 0;
final byte[] dest = {(byte)0};
final int destOff = 2044;
final int destLen = 0;

// Act
thrown.expect(info.ata4.util.lz4.LZ4Exception.class);
objectUnderTest.decompress(src, srcOff, dest, destOff, destLen);

// Method is not expected to return due to exception thrown
}

/*
* Test generated by Diffblue Deeptest.
* This test case covers:
* - conditional line 23 branch to line 24
* - conditional line 24 branch to line 26
* - conditional line 26 branch to line 34
* - conditional line 45 branch to line
* - conditional line 55 branch to line 56
* - conditional line 56 branch to line 57
*/

@Test
public void decompressInput1Zero1ZeroPositiveOutputLZ4Exception() {

// Arrange
final LZ4JavaSafeFastDecompressor objectUnderTest = new LZ4JavaSafeFastDecompressor();
final byte[] src = {(byte)0};
final int srcOff = 0;
final byte[] dest = {(byte)0};
final int destOff = 0;
final int destLen = 1;

// Act
thrown.expect(info.ata4.util.lz4.LZ4Exception.class);
objectUnderTest.decompress(src, srcOff, dest, destOff, destLen);

// Method is not expected to return due to exception thrown
}

/*
* Test generated by Diffblue Deeptest.
* This test case covers:
* - conditional line 23 branch to line 24
* - conditional line 24 branch to line 26
* - conditional line 26 branch to line 27
* - conditional line 27 branch to line 30
*/

@Test
public void decompressInput1ZeroNullPositiveZeroOutputPositive() {

// Arrange
final LZ4JavaSafeFastDecompressor objectUnderTest = new LZ4JavaSafeFastDecompressor();
final byte[] src = {(byte)0};
final int srcOff = 0;
final byte[] dest = null;
final int destOff = 3175;
final int destLen = 0;

// Act
final int retval = objectUnderTest.decompress(src, srcOff, dest, destOff, destLen);

// Assert result
Assert.assertEquals(1, retval);
}

/*
* Test generated by Diffblue Deeptest.This test covers `int decompress(byte
* [], int, byte [], int, int)' block 26 (line 46)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 27 (line 47)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 28 (line 47)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 29 (line 47)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 30 (line 47)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 31 (line 50)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 34 (line 50)
*
*/

@Test
public void decompressInput3Positive3PositivePositiveOutputLZ4Exception() {

// Arrange
final LZ4JavaSafeFastDecompressor objectUnderTest = new LZ4JavaSafeFastDecompressor();
final byte[] src = {(byte)-50, (byte)-2, (byte)27};
final int srcOff = 1;
final byte[] dest = {(byte)0, (byte)0, (byte)0};
final int destOff = 2;
final int destLen = 1;

// Act
thrown.expect(info.ata4.util.lz4.LZ4Exception.class);
objectUnderTest.decompress(src, srcOff, dest, destOff, destLen);

// Method is not expected to return due to exception thrown
}

/*
* Test generated by Diffblue Deeptest.This test covers `int decompress(byte
* [], int, byte [], int, int)' block 26 (line 46)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 27 (line 47)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 28 (line 47)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 29 (line 47)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 30 (line 47)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 31 (line 50)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 32 (line 48)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 33 (line 48)
* This test covers `int decompress(byte [], int, byte [], int, int)' block
* 34 (line 50)
*
*/

@Test
public void decompressInput3Zero3PositivePositiveOutputLZ4Exception() {

// Arrange
final LZ4JavaSafeFastDecompressor objectUnderTest = new LZ4JavaSafeFastDecompressor();
final byte[] src = {(byte)-5, (byte)-1, (byte)0};
final int srcOff = 0;
final byte[] dest = {(byte)0, (byte)0, (byte)0};
final int destOff = 2;
final int destLen = 1;

// Act
thrown.expect(info.ata4.util.lz4.LZ4Exception.class);
objectUnderTest.decompress(src, srcOff, dest, destOff, destLen);

// Method is not expected to return due to exception thrown
}

/*
* Test generated by Diffblue Deeptest.
* This test case covers:
* - conditional line 23 branch to line 24
* - conditional line 24 branch to line 26
* - conditional line 26 branch to line 34
* - conditional line 45 branch to line
* - conditional line 55 branch to line 56
* - conditional line 56 branch to line 60
* - conditional line 60 branch to line 61
*/
@PrepareForTest({LZ4JavaSafeFastDecompressor.class, System.class})
@Test
public void decompressInput3Zero3PositivePositiveOutputPositive() throws Exception {

// Setup mocks
mockStatic(System.class);

// Arrange
final LZ4JavaSafeFastDecompressor objectUnderTest = new LZ4JavaSafeFastDecompressor();
final byte[] src = {(byte)31, (byte)-1, (byte)-1};
final int srcOff = 0;
final byte[] dest = {(byte)0, (byte)0, (byte)0};
final int destOff = 2;
final int destLen = 1;

// Act
final int retval = objectUnderTest.decompress(src, srcOff, dest, destOff, destLen);

// Assert result
Assert.assertEquals(2, retval);
}

}
Loading