Skip to content

Instantly share code, notes, and snippets.

@delucas
Created May 3, 2012 15:54
Show Gist options
  • Save delucas/2586753 to your computer and use it in GitHub Desktop.
Save delucas/2586753 to your computer and use it in GitHub Desktop.
#tallerweb - Rango y pruebas
package ar.edu.unlam.tallerweb.eclipse;
public class Rango {
private int minimo;
private int maximo;
public Rango(int minimo, int maximo){
this.minimo = minimo;
this.maximo = maximo;
}
public boolean contiene(int valor){
boolean retorno = false;
if(valor >= this.minimo
&& valor <= this.maximo){
retorno = true;
}
return retorno;
}
}
package ar.edu.unlam.tallerweb.eclipse;
import org.junit.Assert;
import org.junit.Test;
public class RangoTests {
@Test
public void cuandoElNumeroEstaEnElRangoEsVerdadero(){
Rango ernestor = new Rango(0, 9);
int numero = 4;
Assert.assertTrue(ernestor.contiene(numero));
}
@Test
public void cuandoElNumeroNoEstaEnElRangoEsFalso(){
Rango rango = new Rango(0, 9);
int numero = 10;
Assert.assertFalse(rango.contiene(numero));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment