BAEL-1211 Bubble Sort in Java (#2744)
* BAEL-815 Introduction to JGraphT * BAEL-815 Move code from libraries to algorithms * BAEL-1211 Bubble Sort in Java * BAEL-1211 Bubble Sort in Java * BAEL-1211 Bubble Sort in Java * BAEL-1211 Bubble Sort in Java * BAEL-1211 Fix conflict
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.baeldung.algorithms.bubblesort;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class BubbleSortTest {
|
||||
|
||||
@Test
|
||||
public void givenIntegerArray_whenSortedWithBubbleSort_thenGetSortedArray() {
|
||||
Integer[] array = { 2, 1, 4, 6, 3, 5 };
|
||||
Integer[] sortedArray = { 1, 2, 3, 4, 5, 6 };
|
||||
BubbleSort bubbleSort = new BubbleSort();
|
||||
bubbleSort.bubbleSort(array);
|
||||
assertArrayEquals(array, sortedArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIntegerArray_whenSortedWithOptimizedBubbleSort_thenGetSortedArray() {
|
||||
Integer[] array = { 2, 1, 4, 6, 3, 5 };
|
||||
Integer[] sortedArray = { 1, 2, 3, 4, 5, 6 };
|
||||
BubbleSort bubbleSort = new BubbleSort();
|
||||
bubbleSort.optimizedBubbleSort(array);
|
||||
assertArrayEquals(array, sortedArray);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user