From 318cced06fe29db1dd23eee5564459dd6fee80a6 Mon Sep 17 00:00:00 2001 From: homnay1234 <99612060+homnay1234@users.noreply.github.com> Date: Sun, 20 Feb 2022 22:26:05 +0700 Subject: [PATCH] jUnit Test on Selection Sort I hope i can add a jUnit Test on Selection Sort for your Project --- TestSelectionSort | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 TestSelectionSort diff --git a/TestSelectionSort b/TestSelectionSort new file mode 100644 index 00000000..b98e7b86 --- /dev/null +++ b/TestSelectionSort @@ -0,0 +1,36 @@ +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class TestSort { + + SelectionSort selectionSort = new SelectionSort(); + @Test + public void tesInsertIntoSorted() { + int[] inputArr = new int[] {1,3,5}; + int[] inputResult = new int[] {1,3,5}; + selectionSort.selectionSort(inputArr); + assertArrayEquals(inputResult, inputArr); + } + + SelectionSort selectionSort2 = new SelectionSort(); + @Test + public void tesInsertIntoSorted2() { + int[] inputArr = new int[] {5,3,1}; + int[] inputResult = new int[] {1,3,5}; + selectionSort.selectionSort(inputArr); + assertArrayEquals(inputResult, inputArr); + } + + + SelectionSort selectionSort3 = new SelectionSort(); + @Test + public void tesInsertIntoSorted3() { + int[] inputArr = new int[] {4,5,3,2}; + int[] inputResult = new int[] {2,3,4,5}; + selectionSort.selectionSort(inputArr); + assertArrayEquals(inputResult, inputArr); + } + + +}