WDT-projekt/testy uzupełnione/GuessTheUnitsTest.java
2022-06-21 20:39:10 +02:00

82 lines
1.9 KiB
Java

package com.epam.bootcamp.bmi_calculator;
import static org.junit.Assert.*;
import org.junit.*;
public class GuessTheUnitsTest {
@Test
public void GuessTheUnitsTest1() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(1.7,50.0);
assertEquals(gtu.getUnitType(),"metric");
}
@Test
public void GuessTheUnitsTest2() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(170,50.0);
assertEquals(gtu.getUnitType(),"metric");
}
@Test
public void GuessTheUnitsTest3() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(5.58,1764);
assertEquals(gtu.getUnitType(),"US");
assertEquals(gtu.getWeight(),110,1);
}
@Test
public void GuessTheUnitsTest4() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(65,2000);
assertEquals(gtu.getUnitType(),"US");
assertEquals(gtu.getWeight(),125,1);
}
@Test
public void GuessTheUnitsTest5() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(100,1000);
assertEquals(gtu.getUnitType(),"metric");
}
@Test
public void GuessTheUnitsTest6() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(9.9,3.01);
assertEquals(gtu.getUnitType(),"US");
assertEquals(gtu.getWeight(),3.01,1);
}
@Test
public void GuessTheUnitsTest7() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(2.99,1000);
assertEquals(gtu.getUnitType(),"metric");
}
@Test
public void GuessTheUnitsTest8() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(3,1000);
assertEquals(gtu.getUnitType(),"metric");
}
@Test
public void GuessTheUnitsTest9() throws Exception{
GuessTheUnits gtu = new GuessTheUnits(99.9,1000.1);
assertEquals(gtu.getUnitType(),"US");
assertEquals(gtu.getWeight(),62.50625,0.01);
}
@Test
public void GuessTheUnitsTest10() throws Exception{
try{
GuessTheUnits gtu = new GuessTheUnits(170,1764);
assertEquals(gtu.getUnitType(),"US");
}catch(Exception e){
assertEquals(e.getMessage(),"Height and weight is in different metric.");
}
}
}