1
+ package test .unitTests ;
2
+
3
+ import org .junit .Before ;
4
+ import org .junit .Test ;
5
+ import static org .junit .Assert .*;
6
+
7
+ /**
8
+ * This class has been generated by Muggl for the automated testing of method
9
+ * test.preconditions.InsertionSort.simpleArraySwap(int[] array).
10
+ * Test cases have been computed using the symbolic execution of Muggl. Muggl
11
+ * is a tool for the fully automated generation of test cases by analysing a
12
+ * program's byte code. It aims at testing any possible flow through the program's
13
+ * code rather than "guessing" required test cases, as a human would do.
14
+ * Refer to http://www.wi.uni-muenster.de/pi/personal/majchrzak.php for more
15
+ * information or contact the author at [email protected] .
16
+ *
17
+ * Executing the method main(null) will invoke JUnit (if it is in the class path).
18
+ * The methods for setting up the test and for running the tests have also been
19
+ * annotated.
20
+ *
21
+ * Important settings for this run:
22
+ * Search algorithm: iterative deepening depth first
23
+ * Time Limit: 15 seconds
24
+ * Maximum loop cycles to take: 200
25
+ * Maximum instructions before
26
+ * finding a new solution: infinite
27
+ *
28
+ * The total number of solutions found was 51. After deleting redundancy and
29
+ * removing unnecessary solutions, 51 distinct test cases were found.
30
+ * By eliminating solutions based on their contribution to the
31
+ * def-use chain and control graph edge coverage
32
+ * the total number of solutions could be reduced by 47 to the final number of 4 test cases.
33
+ *
34
+ * Covered def-use chains: 12 of 12
35
+ * Covered control graph edges: 26 of 32
36
+ *
37
+ * This file has been generated on Wednesday, 03 September, 2014 14:06.
38
+ *
39
+ * @author Muggl 1.00 Alpha (unreleased)
40
+ */
41
+ public class TestClass4 {
42
+ // Fields for test parameters and expected return values.
43
+ private test .preconditions .InsertionSort testedClass ;
44
+ private int int1 ;
45
+ private int int0 ;
46
+ private int [] array0 = {0 ,-1 };
47
+ private int [] array1 = {0 ,0 };
48
+ private int [] array2 = null ;
49
+ private int [] array3 = {0 };
50
+
51
+ /**
52
+ * Set up the unit test by initializing the fields to the desired values.
53
+ */
54
+ @ Before public void setUp () {
55
+ this .testedClass = new test .preconditions .InsertionSort ();
56
+ this .int1 = 1 ;
57
+ this .int0 = 0 ;
58
+ }
59
+
60
+ /**
61
+ * Run the tests on test.preconditions.InsertionSort.simpleArraySwap(int[] array).
62
+ */
63
+ @ Test public void testIt () {
64
+ assertEquals (this .int1 , this .testedClass .simpleArraySwap (this .array0 ));
65
+ assertEquals (this .int0 , this .testedClass .simpleArraySwap (this .array1 ));
66
+ try {
67
+ this .testedClass .simpleArraySwap (this .array2 );
68
+ fail ("Expected a java.lang.NullPointerException to be thrown." );
69
+ } catch (java .lang .NullPointerException e ) {
70
+ // Do nothing - this is what we expect to happen!
71
+ }
72
+ try {
73
+ this .testedClass .simpleArraySwap (this .array3 ); // In this solution, not all parameters are used (int array[0] is unused).
74
+ fail ("Expected a java.lang.ArrayIndexOutOfBoundsException to be thrown." );
75
+ } catch (java .lang .ArrayIndexOutOfBoundsException e ) {
76
+ // Do nothing - this is what we expect to happen!
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Invoke JUnit to run the unit tests.
82
+ * @param args Command line arguments, which are ignored here. Just supply null.
83
+ */
84
+ public static void main (String args []) {
85
+ org .junit .runner .JUnitCore .main ("test.unitTests.TestClass4" );
86
+ }
87
+
88
+ }
0 commit comments