added tests
This commit is contained in:
parent
8238e9b462
commit
37fd3b18be
1 changed files with 58 additions and 0 deletions
58
commons/src/test/java/commons/FormalIngredientTest.java
Normal file
58
commons/src/test/java/commons/FormalIngredientTest.java
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
package commons;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class FormalIngredientTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void normaliseGramsToTest(){
|
||||||
|
Ingredient ingredient = new Ingredient("Bread", 1, 2, 3);
|
||||||
|
FormalIngredient toKg = new FormalIngredient(ingredient,1_000,"g");
|
||||||
|
FormalIngredient toTonne = new FormalIngredient(ingredient,1_000_000,"g");
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(toKg.normalisedUnit(),"1.0kg");
|
||||||
|
assertEquals(toTonne.normalisedUnit(),"1.0t");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void normaliseMillilitresToLitresTest(){
|
||||||
|
Ingredient ingredient = new Ingredient("Bread", 1, 2, 3);
|
||||||
|
FormalIngredient toKg = new FormalIngredient(ingredient,1_000,"ml");
|
||||||
|
|
||||||
|
assertEquals(toKg.normalisedUnit(),"1.0l");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void normaliseOunceToPoundTest(){
|
||||||
|
Ingredient ingredient = new Ingredient("Bread", 1, 2, 3);
|
||||||
|
FormalIngredient toPound = new FormalIngredient(ingredient,16,"oz");
|
||||||
|
|
||||||
|
assertEquals(toPound.normalisedUnit(),"1.0lb");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void normaliseTablespoonToTest(){
|
||||||
|
Ingredient ingredient = new Ingredient("Bread", 1, 2, 3);
|
||||||
|
FormalIngredient toCup = new FormalIngredient(ingredient,16,"tbsp");
|
||||||
|
FormalIngredient toPound = new FormalIngredient(ingredient,32,"tbsp");
|
||||||
|
FormalIngredient toOunce = new FormalIngredient(ingredient,2,"tbsp");
|
||||||
|
|
||||||
|
assertEquals(toCup.normalisedUnit(),"1.0cup(s)");
|
||||||
|
assertEquals(toPound.normalisedUnit(),"1.0lb");
|
||||||
|
assertEquals(toOunce.normalisedUnit(),"1.0oz");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void noNormaliseTest(){
|
||||||
|
Ingredient ingredient = new Ingredient("Bread", 1, 2, 3);
|
||||||
|
FormalIngredient informal = new FormalIngredient(ingredient,10,"<NONE>");
|
||||||
|
FormalIngredient toSmall = new FormalIngredient(ingredient,10,"g");
|
||||||
|
|
||||||
|
assertEquals(informal.normalisedUnit(),"10.0<NONE>");
|
||||||
|
assertEquals(toSmall.normalisedUnit(),"10.0g");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue