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:
Parth Karia
2017-10-15 22:27:01 +05:30
committed by maibin
parent 0b5fbdc53e
commit eece3d02ba
2 changed files with 67 additions and 0 deletions
@@ -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);
}
}