-
Notifications
You must be signed in to change notification settings - Fork 842
Expand file tree
/
Copy pathTemperatureTest.java
More file actions
31 lines (24 loc) · 911 Bytes
/
Copy pathTemperatureTest.java
File metadata and controls
31 lines (24 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/** Tests for {@link Temperature}. Do NOT modify this file. */
class TemperatureTest {
private static final double DELTA = 1e-9;
@Test
void fromCelsiusKeepsTheCelsiusValue() {
assertEquals(100.0, Temperature.fromCelsius(100).getCelsius(), DELTA);
}
@Test
void fromCelsiusConvertsToFahrenheit() {
assertEquals(32.0, Temperature.fromCelsius(0).getFahrenheit(), DELTA);
assertEquals(212.0, Temperature.fromCelsius(100).getFahrenheit(), DELTA);
}
@Test
void fromFahrenheitConvertsToCelsius() {
assertEquals(0.0, Temperature.fromFahrenheit(32).getCelsius(), DELTA);
assertEquals(100.0, Temperature.fromFahrenheit(212).getCelsius(), DELTA);
}
@Test
void fromFahrenheitRoundTrips() {
assertEquals(98.6, Temperature.fromFahrenheit(98.6).getFahrenheit(), DELTA);
}
}