Skip to content

Commit 6a3eec1

Browse files
authored
Unit test for MergeSort
1 parent a4521a9 commit 6a3eec1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.baeldung.algorithms.mergesort;
2+
3+
import static org.junit.jupiter.api.Assertions.*;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
class MergeSortTest {
8+
9+
@Test
10+
void positiveTest() {
11+
int[] input = { 5, 1, 6, 2, 3, 4 };
12+
int[] expected = { 1, 2, 3, 4, 5, 6 };
13+
MergeSort.mergeSort(input, input.length);
14+
assertArrayEquals(expected, input);
15+
}
16+
17+
@Test
18+
void negativeTest() {
19+
int[] input = { 5, 1, 6, 2, 3, 4 };
20+
int[] expected = { 1, 2, 3, 4, 6, 5 };
21+
MergeSort.mergeSort(input, input.length);
22+
assertArrayEquals(expected, input);
23+
}
24+
25+
}

0 commit comments

Comments
 (0)