Unit test for MergeSort

This commit is contained in:
Vaibhav Sahay 2018-09-29 16:06:30 +05:30 committed by GitHub
parent a4521a9b04
commit 6a3eec15e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package com.baeldung.algorithms.mergesort;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class MergeSortTest {
@Test
void positiveTest() {
int[] input = { 5, 1, 6, 2, 3, 4 };
int[] expected = { 1, 2, 3, 4, 5, 6 };
MergeSort.mergeSort(input, input.length);
assertArrayEquals(expected, input);
}
@Test
void negativeTest() {
int[] input = { 5, 1, 6, 2, 3, 4 };
int[] expected = { 1, 2, 3, 4, 6, 5 };
MergeSort.mergeSort(input, input.length);
assertArrayEquals(expected, input);
}
}