19
19
20
20
import org .bosik .diacomp .core .entities .business .FoodMassed ;
21
21
import org .bosik .diacomp .core .persistence .serializers .SerializerFoodMassedPlain ;
22
+ import org .bosik .diacomp .core .utils .Utils ;
22
23
import org .junit .Test ;
23
24
24
25
import java .text .DecimalFormatSymbols ;
27
28
28
29
public class TestSerializerFoodMassedPlain
29
30
{
30
- private static final double EPS = 0.01 ;
31
- private final SerializerFoodMassedPlain serializer = new SerializerFoodMassedPlain ();
31
+ private final SerializerFoodMassedPlain serializer = new SerializerFoodMassedPlain ();
32
32
33
33
@ Test
34
34
public void test_read_normalDots_Ok ()
35
35
{
36
36
// with dots
37
37
FoodMassed food = serializer .read ("Колбаса[12.7|19.1|0|270]:40" );
38
38
assertEquals ("Колбаса" , food .getName ());
39
- assertEquals (12.7 , food .getRelProts (), EPS );
40
- assertEquals (19.1 , food .getRelFats (), EPS );
41
- assertEquals (0.0 , food .getRelCarbs (), EPS );
42
- assertEquals (270.0 , food .getRelValue (), EPS );
43
- assertEquals (40.0 , food .getMass (), EPS );
39
+ assertEquals (12.7 , food .getRelProts (), Utils . EPS );
40
+ assertEquals (19.1 , food .getRelFats (), Utils . EPS );
41
+ assertEquals (0.0 , food .getRelCarbs (), Utils . EPS );
42
+ assertEquals (270.0 , food .getRelValue (), Utils . EPS );
43
+ assertEquals (40.0 , food .getMass (), Utils . EPS );
44
44
}
45
45
46
46
@ Test
@@ -49,11 +49,11 @@ public void test_read_mixedDots_Ok()
49
49
// with both dots and commas
50
50
FoodMassed food = serializer .read ("Колбаса[12,7|19.1|0|270]:40" );
51
51
assertEquals ("Колбаса" , food .getName ());
52
- assertEquals (12.7 , food .getRelProts (), EPS );
53
- assertEquals (19.1 , food .getRelFats (), EPS );
54
- assertEquals (0.0 , food .getRelCarbs (), EPS );
55
- assertEquals (270.0 , food .getRelValue (), EPS );
56
- assertEquals (40.0 , food .getMass (), EPS );
52
+ assertEquals (12.7 , food .getRelProts (), Utils . EPS );
53
+ assertEquals (19.1 , food .getRelFats (), Utils . EPS );
54
+ assertEquals (0.0 , food .getRelCarbs (), Utils . EPS );
55
+ assertEquals (270.0 , food .getRelValue (), Utils . EPS );
56
+ assertEquals (40.0 , food .getMass (), Utils . EPS );
57
57
}
58
58
59
59
@ Test (expected = IllegalArgumentException .class )
0 commit comments