|
@@ -0,0 +1,113 @@
|
|
1
|
+import static org.junit.Assert.assertEquals;
|
|
2
|
+import org.junit.Test;
|
|
3
|
+
|
|
4
|
+public class ConversionToolSpec {
|
|
5
|
+
|
|
6
|
+ @Test
|
|
7
|
+ public void shouldConvertCentimetersToInches() {
|
|
8
|
+ float inches = ConversionTool.CentimetersToInches(2f);
|
|
9
|
+ assertEquals(0.7874f, inches, 0.001);
|
|
10
|
+ }
|
|
11
|
+ @Test
|
|
12
|
+ public void shouldConvertZeroCentimetersToZeroInches() {
|
|
13
|
+ float inches = ConversionTool.CentimetersToInches(0);
|
|
14
|
+ assertEquals(0, inches, 0.0);
|
|
15
|
+ }
|
|
16
|
+ @Test
|
|
17
|
+ public void shouldConvertNegativeCentimetersToZeroInches() {
|
|
18
|
+ float inches = ConversionTool.CentimetersToInches(-5);
|
|
19
|
+ assertEquals(0, inches, 0.0);
|
|
20
|
+ }
|
|
21
|
+
|
|
22
|
+ @Test
|
|
23
|
+ public void shouldConvertInchesToCentimeters() {
|
|
24
|
+ float centimeters = ConversionTool.InchesToCentimeters(4f);
|
|
25
|
+ assertEquals(10.16f, centimeters, 0.001);
|
|
26
|
+ }
|
|
27
|
+ @Test
|
|
28
|
+ public void shouldConvertZeroInchesToZeroCentimeters() {
|
|
29
|
+ float centimeters = ConversionTool.InchesToCentimeters(0);
|
|
30
|
+ assertEquals(0, centimeters, 0.0);
|
|
31
|
+ }
|
|
32
|
+ @Test
|
|
33
|
+ public void shouldConvertNegativeInchesToZeroCentimeters() {
|
|
34
|
+ float centimeters = ConversionTool.InchesToCentimeters(-5);
|
|
35
|
+ assertEquals(0, centimeters, 0.0);
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ @Test
|
|
39
|
+ public void shouldConvertFeetToMeters() {
|
|
40
|
+ float meters = ConversionTool.FeetToMeters(5f);
|
|
41
|
+ assertEquals(1.524f, meters, 0.001);
|
|
42
|
+ }
|
|
43
|
+ @Test
|
|
44
|
+ public void shouldConvertZeroFeetToZeroMeters() {
|
|
45
|
+ float meters = ConversionTool.FeetToMeters(0);
|
|
46
|
+ assertEquals(0, meters, 0.0);
|
|
47
|
+ }
|
|
48
|
+ @Test
|
|
49
|
+ public void shouldConvertNegativeFeetToZeroMeters() {
|
|
50
|
+ float meters = ConversionTool.FeetToMeters(-10);
|
|
51
|
+ assertEquals(0, meters, 0.0);
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ @Test
|
|
55
|
+ public void shouldConvertMetersToFeet() {
|
|
56
|
+ float feet = ConversionTool.MetersToFeet(9f);
|
|
57
|
+ assertEquals(29.5276f, feet, 0.001);
|
|
58
|
+ }
|
|
59
|
+ @Test
|
|
60
|
+ public void shouldConvertZeroMetersToZeroFeet() {
|
|
61
|
+ float feet = ConversionTool.MetersToFeet(0);
|
|
62
|
+ assertEquals(0, feet, 0.0);
|
|
63
|
+ }
|
|
64
|
+ @Test
|
|
65
|
+ public void shouldConvertNegativeMetersToZeroFeet() {
|
|
66
|
+ float feet = ConversionTool.MetersToFeet(-10);
|
|
67
|
+ assertEquals(0, feet, 0.0);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ @Test
|
|
71
|
+ public void shouldConvertFahrenheitToCelsius() {
|
|
72
|
+ float celsius = ConversionTool.FahrenheitToCelsius(80);
|
|
73
|
+ assertEquals(26.67, celsius, 0.01);
|
|
74
|
+ }
|
|
75
|
+ @Test
|
|
76
|
+ public void shouldConvertCelsiusToFahrenheit() {
|
|
77
|
+ float fahrenheit = ConversionTool.CelsiusToFahrenheit(26.67f);
|
|
78
|
+ assertEquals(80, fahrenheit, 0.01);
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ @Test
|
|
82
|
+ public void shouldConvertMphToKph(){
|
|
83
|
+ float kph = ConversionTool.MphToKph(24f);
|
|
84
|
+ assertEquals(38.62, kph, 0.01);
|
|
85
|
+ }
|
|
86
|
+ @Test
|
|
87
|
+ public void shouldConvertZeroMphToZeroKph(){
|
|
88
|
+ float kph = ConversionTool.MphToKph(0f);
|
|
89
|
+ assertEquals(0, kph, 0.0);
|
|
90
|
+ }
|
|
91
|
+ @Test
|
|
92
|
+ public void shouldConvertNegativeMphToZeroKph(){
|
|
93
|
+ float kph = ConversionTool.MphToKph(-50f);
|
|
94
|
+ assertEquals(0, kph, 0.0);
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ @Test
|
|
98
|
+ public void shouldConvertKphToMph(){
|
|
99
|
+ float mph = ConversionTool.KphToMph(6.44f);
|
|
100
|
+ assertEquals(4, mph, 0.01);
|
|
101
|
+ }
|
|
102
|
+ @Test
|
|
103
|
+ public void shouldConvertZeroKphToZeroMph(){
|
|
104
|
+ float mph = ConversionTool.KphToMph(0f);
|
|
105
|
+ assertEquals(0, mph, 0.0);
|
|
106
|
+ }
|
|
107
|
+ @Test
|
|
108
|
+ public void shouldConvertNegativeKphToZeroMph(){
|
|
109
|
+ float mph = ConversionTool.KphToMph(-50f);
|
|
110
|
+ assertEquals(0, mph, 0.0);
|
|
111
|
+ }
|
|
112
|
+
|
|
113
|
+}
|