From c68f41633708076501e7f3c1068d971dd9a14003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rodrigues?= Date: Mon, 8 Nov 2021 07:28:26 -0300 Subject: [PATCH] add: adiciona testes para a classe BubbleSort.java --- src/test/java/edu/ifrs/vvs/AppTest.java | 4 +- .../java/edu/ifrs/vvs/BubbleSortTest.java | 50 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/test/java/edu/ifrs/vvs/BubbleSortTest.java diff --git a/src/test/java/edu/ifrs/vvs/AppTest.java b/src/test/java/edu/ifrs/vvs/AppTest.java index 9677aa5..439a72c 100644 --- a/src/test/java/edu/ifrs/vvs/AppTest.java +++ b/src/test/java/edu/ifrs/vvs/AppTest.java @@ -30,6 +30,8 @@ class AppTest { */ @Test void testApp() { - assertEquals(1, 1); + int expected = 1; + int actual = 1; + assertEquals(expected, actual); } } diff --git a/src/test/java/edu/ifrs/vvs/BubbleSortTest.java b/src/test/java/edu/ifrs/vvs/BubbleSortTest.java new file mode 100644 index 0000000..76ad2be --- /dev/null +++ b/src/test/java/edu/ifrs/vvs/BubbleSortTest.java @@ -0,0 +1,50 @@ +package edu.ifrs.vvs; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + +import org.junit.jupiter.api.Test; + +public class BubbleSortTest { + + BubbleSort bubbleSort = new BubbleSort(); + + @Test + public void mustReturnArrayWithNoRepeatedElementsSortedArray() { + int[] actual = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + int[] expected = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + bubbleSort.sort(actual); + + assertArrayEquals(expected, actual); + } + + @Test + public void mustReturnArrayWithNoRepeatedElementsUnsortedArray() { + int[] actual = new int[] { 5, 3, 1, 4, 2, 7, 6, 9, 8 }; + int[] expected = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + bubbleSort.sort(actual); + + assertArrayEquals(expected, actual); + } + + @Test + public void mustReturnArrayWithRepeatedElementsSortedArray() { + int[] actual = new int[] { 1, 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9 }; + int[] expected = new int[] { 1, 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9 }; + + bubbleSort.sort(actual); + + assertArrayEquals(expected, actual); + } + + @Test + public void mustReturnArrayWithRepeatedElementsUnsortedArray() { + int[] actual = new int[] { 5, 3, 1, 7, 3, 4, 2, 7, 6, 9, 8, 5 }; + int[] expected = new int[] { 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9 }; + + bubbleSort.sort(actual); + + assertArrayEquals(expected, actual); + } +}