-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2620 from AstrarothDLCXVI/patch-3
#13-java
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} |