Skip to content

Commit

Permalink
Merge pull request #2620 from AstrarothDLCXVI/patch-3
Browse files Browse the repository at this point in the history
#13-java
  • Loading branch information
kontroldev authored Mar 29, 2024
2 parents a073079 + 49e6ec7 commit e6f99ad
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Roadmap/13 - PRUEBAS UNITARIAS/java/AstrarothDLCXVI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public class Astra {

/*
* Funcion que devuelve la suma de 2 numeros enteros*/
public int sumar(int num1, int num2) {
int sol = 0;

sol = num1 + num2;
System.out.println(sol);
return sol;
}
}



//Test

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

class SumarTest {

@Test
void testSumar() {
Astra llamar = new Astra();

/*numero positivo en los 2 numeros*/
assertEquals(20, llamar.sumar(10, 10));
/*numero positivo y negativo en los 2 con resultado positivo*/
assertEquals(2, llamar.sumar(5, -3));
assertEquals(5, llamar.sumar(-5, 10));
/*numero positivo y negativo en los 2 con resultado negativo*/
assertEquals(-8, llamar.sumar(-10, 2));
assertEquals(-8, llamar.sumar(2, -10));
}

}

0 comments on commit e6f99ad

Please sign in to comment.