From 6a3eec15e55541876a951543a0e6584f18eb83cc Mon Sep 17 00:00:00 2001 From: Vaibhav Sahay Date: Sat, 29 Sep 2018 16:06:30 +0530 Subject: [PATCH] Unit test for MergeSort --- .../algorithms/mergesort/MergeSortTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 algorithms/src/test/java/com/baeldung/algorithms/mergesort/MergeSortTest.java 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); + } + +}