From 0e6edb1a1b91d8e5d1b5c3e3ebcc435cd19d33f1 Mon Sep 17 00:00:00 2001 From: Alexandre Fabian Date: Thu, 22 Sep 2022 17:26:59 -0300 Subject: [PATCH] Implementado testes unitarios para o BubbleSort -tarefa vvs --- src/test/java/edu/ifrs/vvs/AppTest.java | 89 ++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 9 deletions(-) diff --git a/src/test/java/edu/ifrs/vvs/AppTest.java b/src/test/java/edu/ifrs/vvs/AppTest.java index 9677aa5..2bb5822 100644 --- a/src/test/java/edu/ifrs/vvs/AppTest.java +++ b/src/test/java/edu/ifrs/vvs/AppTest.java @@ -17,19 +17,90 @@ package edu.ifrs.vvs; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + -/** - * Unit test for simple App. - */ class AppTest { - /** - * Rigorous Test. - */ + + + @Test + @DisplayName("test 1 elemento") + @Order(1) + void testAppOneElement() { + BubbleSort buuble = new BubbleSort(); + int v[] = {1}; + int v2[] = {1}; + buuble.sort(v); + assertArrayEquals(v, v2); + } + + @Test + @DisplayName("test 2 elementos") + @Order(2) + void testAppTwoElements() { + BubbleSort buuble = new BubbleSort(); + int v[] = {1, 2}; + int v2[] = {1, 2}; + buuble.sort(v); + assertArrayEquals(v, v2); + } + + @Test + @DisplayName("test 2 elementos invertidos") + @Order(3) + void testApp2ElementsReverse() { + BubbleSort buuble = new BubbleSort(); + int v[] = {2, 1}; + int v2[] = {1, 2}; + buuble.sort(v); + assertArrayEquals(v, v2); + } + + @Test + @DisplayName("test More elementos sortidos") + @Order(4) + void testAppMoreElementsSorted() { + BubbleSort buuble = new BubbleSort(); + int v[] = {2, 1, 5, 4, 3, 8, 7, 6}; + int v2[] = {1, 2, 3, 4, 5, 6, 7, 8}; + buuble.sort(v); + assertArrayEquals(v, v2); + } + + @Test + @DisplayName("test elementos sortidos faltando") + @Order(1) + void testAppMissingSomeElementsSorted() { + BubbleSort buuble = new BubbleSort(); + int v[] = {2, 1, 5, 3, 7, 6}; + int v2[] = {1, 2, 3, 5, 6, 7}; + buuble.sort(v); + assertArrayEquals(v, v2); + } + + @Test + @DisplayName("test elementos sortidos faltando com zero") + @Order(2) + void testAppElementsSortedwithZero() { + BubbleSort buuble = new BubbleSort(); + int v[] = {2, 1, 18015, 5, 3, 0, 6}; + int v2[] = {0, 1, 2, 3, 5, 6, 18015}; + buuble.sort(v); + assertArrayEquals(v, v2); + } + @Test - void testApp() { - assertEquals(1, 1); + @DisplayName("test elementos sortidos faltando com zero e negativos") + @Order(3) + void testAppElementsSortedwithZeroandNegatives() { + BubbleSort buuble = new BubbleSort(); + int v[] = {2, 1, 5, -10, 3, 1589, 0, 6}; + int v2[] = {-10, 0, 1, 2, 3, 5, 6, 1589}; + buuble.sort(v); + assertArrayEquals(v, v2); } }