Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teste BubbleSort #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/edu/ifrs/vvs/BubbleSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -49,6 +49,7 @@ public void sort(int... v) {
}
}
}
return v; // ESSA LINHA EU COLOQUEI PRA TESTAR ESSE METODO SORT
}

/**
Expand All @@ -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;
Expand Down
55 changes: 55 additions & 0 deletions src/test/java/edu/ifrs/vvs/BubbleSortTest.java
Original file line number Diff line number Diff line change
@@ -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()));
}
*/

}