package com.mergesort;

import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.Random;

public class MergeSortTest {

    @Test()
    public void mergeSortTest() throws Exception {
        for (int i = 0; i < 100; i++) {
            int[] arr = new int[50];
            Random random = new Random();
            for (int j = 0; j < arr.length; j++) {
                arr[j] = random.nextInt(200);
            }
            MergeSort.doSort(arr);
            for (int j = 0; j < arr.length - 1; j++) {
                if(arr[j] > arr[j+1]) {
                    Assert.fail("The previous element cannot be more than the next one");
                }
            }
        }
    }

    @Test()
    public void mergeSortTest2() throws Exception {
        int[] initial = {4, 7, 0, -10};
        int[] expected = {-10, 0, 4, 7};
        MergeSort.doSort(initial);
        Assert.assertArrayEquals(expected, initial);
    }

    @Test()
    public void mergeSortTest3() throws Exception {
        int[] initial = {4, 7, 0, -10, -7};
        int[] expected = {4, 7, 0, -10, -7};
        MergeSort.doSort(initial);
        Arrays.sort(expected);
        Assert.assertArrayEquals(expected, initial);
    }

}
@@ -170,33 +170,55 @@
 public void 
-m
+randomDataArrayForTestM
 ergeSort
 Test() throw
@@ -205,20 +205,16 @@
 ergeSort
-Test
 () throw
@@ -259,11 +259,9 @@
 i %3C 
-100
+5
 ; i+
@@ -298,17 +298,16 @@
 ew int%5B5
-0
 %5D;%0A     
@@ -747,33 +747,62 @@
 public void 
-m
+differentDemoDataArrayForTestM
 ergeSort
 Test2() thro
@@ -793,13 +793,8 @@
 Sort
-Test2
 () t
@@ -817,39 +817,45 @@
 %7B%0A        int%5B%5D 
-initial
+actualResults
  = %7B4, 7, 0, -10
@@ -875,24 +875,31 @@
 t%5B%5D expected
+Results
  = %7B-10, 0, 
@@ -922,39 +922,45 @@
 ergeSort.doSort(
-initial
+actualResults
 );%0A        Asser
@@ -983,33 +983,46 @@
 als(expected
-, initial
+Results, actualResults
 );%0A    %7D%0A%0A  
@@ -1051,17 +1051,44 @@
 oid 
-m
+identicDemoDataArrayForTestM
 ergeSort
 Test
@@ -1087,13 +1087,8 @@
 Sort
-Test3
 () t
@@ -1119,23 +1119,29 @@
   int%5B%5D 
-initial
+actualResults
  = %7B4, 7
@@ -1177,16 +1177,23 @@
 expected
+Results
  = %7B4, 7
@@ -1232,23 +1232,29 @@
 .doSort(
-initial
+actualResults
 );%0A     
@@ -1276,16 +1276,23 @@
 expected
+Results
 );%0A     
@@ -1331,17 +1331,30 @@
 cted
-, initial
+Results, actualResults
 );%0A 

fix JUnit test