diff --git a/src/main/java/edu/ifrs/vvs/BubbleSort.java b/src/main/java/edu/ifrs/vvs/BubbleSort.java index d548e4b..4d09ee0 100644 --- a/src/main/java/edu/ifrs/vvs/BubbleSort.java +++ b/src/main/java/edu/ifrs/vvs/BubbleSort.java @@ -33,7 +33,7 @@ public class BubbleSort { * * @param v - Vetor que serĂ¡ ordenado. */ - public void sort(int... v) { + public int[] sort(int... v) { // for utilizado para controlar a quantidade de vezes que o vetor serĂ¡ ordenado. for (int i = 0; i < v.length - 1; i++) { // for utilizado para ordenar o vetor. @@ -49,6 +49,7 @@ public void sort(int... v) { } } } + return v; // ESSA LINHA EU COLOQUEI PRA TESTAR ESSE METODO SORT } /** @@ -71,7 +72,7 @@ public int[] read() { * * @return the size of the array */ - private int size() { + public int size() { //MUDEI DE private PARA public PARA FAZER O TESTE System.out.print("Size of array: "); int size = Integer.valueOf(this.scanner.next()); return size; 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..286120b --- /dev/null +++ b/src/test/java/edu/ifrs/vvs/BubbleSortTest.java @@ -0,0 +1,55 @@ +package edu.ifrs.vvs; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; + +public class BubbleSortTest { + + BubbleSort bs = new BubbleSort(); + + + int[] ar = {2,3,1,4}; + int[] art = {1,2,3,4}; + int[] art2 = {2,2,2,2}; + + @Test + @Order(1) + public void ordenaArray() + { + assertArrayEquals(art, bs.sort(ar)); + } + +/* + // ABAIXO AS TENTATIVAS DE TESTE DOS DEMAIS METODOS + @Test + @Order(3) + public void tamanhoArray() + { + //assertArrayEquals(4, bs.size(ar)); + } + @Test + @Order(1) + public void montaArray() + { + //assertArrayEquals(art, bs.read(), ar); + } + + @Test + @Order(1) + public void leArray() + { + //assertArrayEquals(art, bs.read(), ar); + } + + @Test + @Order(1) + public void bteste() + { + assertArrayEquals(bs.show() , bs.sort(bs.read())); + } +*/ + +}