diff --git a/src/main/java/com/github/pedrovgs/problem74/BubbleSort.java b/src/main/java/com/github/pedrovgs/problem74/BubbleSort.java index d8cb56e6..f04d2fab 100644 --- a/src/main/java/com/github/pedrovgs/problem74/BubbleSort.java +++ b/src/main/java/com/github/pedrovgs/problem74/BubbleSort.java @@ -25,6 +25,7 @@ */ public class BubbleSort extends SortingAlgorithm { + /** * Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that * repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps diff --git a/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java b/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java index b022e231..a94b842b 100644 --- a/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java +++ b/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java @@ -46,4 +46,30 @@ public class MultiplicationWithoutMultiplyTest { @Test public void shouldTakeIntoAccountNegativeNumbers() { assertEquals(-14, multiply.calculate(-2, 7)); } + + /** + * This tests for Testing HomeWord - Dinh The Hiep - 17020731 + */ + + //Testing with both negative n1,n2 (n1 < 0, n2 < 0) + @Test + public void test1() { + assertEquals(5600, multiply.calculate(-70,-80)); + } + //Testing with n1 > 0, n2 >0 + @Test + public void test2() { + assertEquals(484, multiply.calculate(44, 11)); + } + //Testing with n1 > 0, n2 < 0 + @Test + public void test3() { + assertEquals(-1500, multiply.calculate(500, -3)); + } + //Testing with n2 > 0, n1 < 0 + @Test + public void test4() { + assertEquals(-4500, multiply.calculate(3, -1500)); + } + } diff --git a/src/test/java/com/github/pedrovgs/problem74/BubbleSortTest2.java b/src/test/java/com/github/pedrovgs/problem74/BubbleSortTest2.java new file mode 100644 index 00000000..ced7e2e6 --- /dev/null +++ b/src/test/java/com/github/pedrovgs/problem74/BubbleSortTest2.java @@ -0,0 +1,45 @@ +package com.github.pedrovgs.problem74; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class BubbleSortTest2 { + @Test + public void Intsort(){ + int[] input = { 1, 2, 4, 3 }; + int[] expectedArray = { 1, 2, 3, 4 }; + BubbleSort bubbleSort = new BubbleSort(); + bubbleSort.sort(input); + assertArrayEquals(expectedArray,input); + } + + @Test + public void Doublesort(){ + int[] input = {-100,63,-62,6}; + int[] expectedArray = { 1, 2, 3, 4 }; + BubbleSort bubbleSort = new BubbleSort(); + bubbleSort.sort(input); + assertArrayEquals(expectedArray,input); + } + + @Test + public void Randomsort(){ + int[] input = { 5,-541,56,45,26}; + int[] expectedArray = { 1, 2, 3, 4 }; + BubbleSort bubbleSort = new BubbleSort(); + bubbleSort.sort(input); + assertArrayEquals(expectedArray,input); + } + + @Test + public void RanDomsort(){ + int[] input = { 10,559,-65,622,-65,-6}; + int[] expectedArray = { 1, 2, 3, 4 }; + BubbleSort bubbleSort = new BubbleSort(); + bubbleSort.sort(input); + assertArrayEquals(expectedArray,input); + } + + +} \ No newline at end of file