From 25dc23fc02166e948893df287f5969475ebce091 Mon Sep 17 00:00:00 2001 From: 17020731 Date: Wed, 18 Sep 2019 23:40:20 +0700 Subject: [PATCH 1/3] testing homework --- .../MultiplicationWithoutMultiplyTest.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java b/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java index b022e231..e129891f 100644 --- a/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java +++ b/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java @@ -46,4 +46,62 @@ public class MultiplicationWithoutMultiplyTest { @Test public void shouldTakeIntoAccountNegativeNumbers() { assertEquals(-14, multiply.calculate(-2, 7)); } + + /** + * This tests for Testing HomeWord - Dinh The Hiep - 17020731 + */ + @Test + public void test1() { + assertEquals(-2147483648, multiply.calculate(18092019, Integer.MIN_VALUE)); + } + + @Test + public void test2() { + assertEquals(-1823452685, multiply.calculate(18092019, -999999999)); + } + + @Test + public void test3() { + assertEquals(919590144, multiply.calculate(18092019, -900000000)); + } + @Test + public void test4() { + assertEquals(-919590144, multiply.calculate(18092019, 900000000)); + } + @Test + public void test5() { + assertEquals(1823452685, multiply.calculate(18092019, 999999999)); + } + @Test + public void test6() { + assertEquals(2129391629, multiply.calculate(18092019, Integer.MAX_VALUE)); + } + @Test + public void test7() { + assertEquals(0, multiply.calculate(Integer.MIN_VALUE, 18092019)); + } + @Test + public void test8() { + assertEquals(-1823452685, multiply.calculate(-999999999, 18092019)); + } + @Test + public void test9() { + assertEquals(919590144, multiply.calculate(-900000000, 18092019)); + } + @Test + public void test10() { + assertEquals(-919590144, multiply.calculate(900000000, 18092019)); + } + @Test + public void test11() { + assertEquals(1823452685, multiply.calculate(999999999, 18092019)); + } + @Test + public void test12() { + assertEquals(2129391629, multiply.calculate(Integer.MAX_VALUE, 18092019)); + } + @Test + public void test13() { + assertEquals(1693868201,multiply.calculate(18092019, 18092019)); + } } From 7b46b405bbf8efef5bccbcb086bc0d83d5e3ecf7 Mon Sep 17 00:00:00 2001 From: 17020731 Date: Fri, 27 Sep 2019 00:08:02 +0700 Subject: [PATCH 2/3] Testing Control Flow --- .../MultiplicationWithoutMultiplyTest.java | 52 ++++--------------- 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java b/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java index e129891f..a94b842b 100644 --- a/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java +++ b/src/test/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiplyTest.java @@ -50,58 +50,26 @@ public class MultiplicationWithoutMultiplyTest { /** * This tests for Testing HomeWord - Dinh The Hiep - 17020731 */ + + //Testing with both negative n1,n2 (n1 < 0, n2 < 0) @Test public void test1() { - assertEquals(-2147483648, multiply.calculate(18092019, Integer.MIN_VALUE)); + assertEquals(5600, multiply.calculate(-70,-80)); } - + //Testing with n1 > 0, n2 >0 @Test public void test2() { - assertEquals(-1823452685, multiply.calculate(18092019, -999999999)); + assertEquals(484, multiply.calculate(44, 11)); } - + //Testing with n1 > 0, n2 < 0 @Test public void test3() { - assertEquals(919590144, multiply.calculate(18092019, -900000000)); + assertEquals(-1500, multiply.calculate(500, -3)); } + //Testing with n2 > 0, n1 < 0 @Test public void test4() { - assertEquals(-919590144, multiply.calculate(18092019, 900000000)); - } - @Test - public void test5() { - assertEquals(1823452685, multiply.calculate(18092019, 999999999)); - } - @Test - public void test6() { - assertEquals(2129391629, multiply.calculate(18092019, Integer.MAX_VALUE)); - } - @Test - public void test7() { - assertEquals(0, multiply.calculate(Integer.MIN_VALUE, 18092019)); - } - @Test - public void test8() { - assertEquals(-1823452685, multiply.calculate(-999999999, 18092019)); - } - @Test - public void test9() { - assertEquals(919590144, multiply.calculate(-900000000, 18092019)); - } - @Test - public void test10() { - assertEquals(-919590144, multiply.calculate(900000000, 18092019)); - } - @Test - public void test11() { - assertEquals(1823452685, multiply.calculate(999999999, 18092019)); - } - @Test - public void test12() { - assertEquals(2129391629, multiply.calculate(Integer.MAX_VALUE, 18092019)); - } - @Test - public void test13() { - assertEquals(1693868201,multiply.calculate(18092019, 18092019)); + assertEquals(-4500, multiply.calculate(3, -1500)); } + } From 27e84cf750c57a8d86661906a2549238547647be Mon Sep 17 00:00:00 2001 From: 17020731 Date: Sat, 28 Sep 2019 23:45:03 +0700 Subject: [PATCH 3/3] Testing HomeWork --- .../github/pedrovgs/problem74/BubbleSort.java | 1 + .../pedrovgs/problem74/BubbleSortTest2.java | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/test/java/com/github/pedrovgs/problem74/BubbleSortTest2.java 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/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