package com.mergesort;

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

public class MergeSortTest {

    @Test()
    public void evenValueDemoDataArray() throws Exception {
        int[] actualResults = {4, 7, 0, -10};
        int[] expectedResults = {-10, 0, 4, 7};
        MergeSort.doSort(actualResults);
        Assert.assertArrayEquals(expectedResults, actualResults);
        System.out.println("Test \"evenValueDemoDataArray\" complete!");
    }

    @Test()
    public void oddValueForDemoDataArray() throws Exception {
        int[] actualResults = {4, 7, 0, -10, 100500};
        int[] expectedResults = {-10, 0, 4, 7, 100500};
        MergeSort.doSort(actualResults);
        Assert.assertArrayEquals(expectedResults, actualResults);
        System.out.println("Test \"oddValueForDemoDataArray\" complete!");
    }

    @Test()
    public void boundaryValueForDemoDataArray() throws Exception {
        int[] actualResults = {0, -1, 2, -2, 1};
        int[] expectedResults = {-2, -1, 0, 1, 2};
        MergeSort.doSort(actualResults);
        Assert.assertArrayEquals(expectedResults, actualResults);
        System.out.println("Test \"boundaryValueForDemoDataArray\" complete!");
    }

    @Test()
    public void boundaryIntTypeValueForDemoDataArray() throws Exception {
        int[] actualResults = {7, 0, -2147483648, 2147483647, 10};
        int[] expectedResults = {-2147483648, 0, 7, 10, 2147483647};
        MergeSort.doSort(actualResults);
        Assert.assertArrayEquals(expectedResults, actualResults);
        System.out.println("Test \"boundaryIntTypeValueForDemoDataArray\" complete!");
    }

    @Test()
    public void identicalValueForDemoDataArray() throws Exception {
        int[] actualResults = {0, 1, 2, 0, 0};
        int[] expectedResults = {0, 0, 0, 1, 2};
        MergeSort.doSort(actualResults);
        Assert.assertArrayEquals(expectedResults, actualResults);
        System.out.println("Test \"identicalValueForDemoDataArray\" complete!");
    }

    @Test()
    public void twoDifferentMethodsOfSorting() throws Exception {
        int[] actualResults = {4, 7, 0, -10, -7};
        int[] expectedResults = {4, 7, 0, -10, -7};
        MergeSort.doSort(actualResults);
        Arrays.sort(expectedResults);
        Assert.assertArrayEquals(expectedResults, actualResults);
        System.out.println("Test \"twoDifferentMethodsOfSorting\" complete!");
    }

    @Ignore("Incorrect test!!! Should not to do, bad test.")
    @Test()
    public void randomValueDemoDataArray() throws Exception {
        for (int i = 0; i < 5; i++) {
            int[] arr = new int[5];
            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");
                }
            }
        }
    }
}
@@ -479,38 +479,42 @@
 %22Test %5C%22even
-V
+ v
 alue
-DemoDataA
+ demo data a
 rray%5C%22 compl
@@ -857,33 +857,38 @@
 st %5C%22odd
-V
+ v
 alue
-ForDemoDataA
+ for demo data a
 rray%5C%22 c
@@ -1235,33 +1235,38 @@
 boundary
-V
+ v
 alue
-ForDemoDataA
+ for demo data a
 rray%5C%22 c
@@ -1660,32 +1660,39 @@
 dary
+ 
 Int
-TypeV
+ type v
 alue
-ForDemoDataA
+ for demo data a
 rray
@@ -2041,33 +2041,38 @@
 dentical
-V
+ v
 alue
-ForDemoDataA
+ for demo data a
 rray%5C%22 c
@@ -2453,25 +2453,26 @@
 st %5C%22two
-D
+ d
 ifferent
 MethodsO
@@ -2459,34 +2459,37 @@
 wo different
-M
+ m
 ethods
-OfS
+ of s
 orting%5C%22 com

fix JUnit