diff --git a/algorithms/src/test/java/com/baeldung/algorithms/mergesort/MergeSortTest.java b/algorithms/src/test/java/com/baeldung/algorithms/mergesort/MergeSortTest.java new file mode 100644 index 0000000000..5c304ba7fe --- /dev/null +++ b/algorithms/src/test/java/com/baeldung/algorithms/mergesort/MergeSortTest.java @@ -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); + } + +}