Skip to content

Commit 44f9fd1

Browse files
authored
added tests (TheAlgorithms#2234)
1 parent 99b40e2 commit 44f9fd1

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

‎conversions/temperature_conversions.py

+40
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ def celsius_to_fahrenheit(celsius: float, ndigits: int = 2) -> float:
77
Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
88
Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
99
10+
>>> celsius_to_fahrenheit(273.354, 3)
11+
524.037
12+
>>> celsius_to_fahrenheit(273.354, 0)
13+
524.0
1014
>>> celsius_to_fahrenheit(-40.0)
1115
-40.0
1216
>>> celsius_to_fahrenheit(-20.0)
@@ -31,6 +35,10 @@ def celsius_to_kelvin(celsius: float, ndigits: int = 2) -> float:
3135
Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
3236
Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
3337
38+
>>> celsius_to_kelvin(273.354, 3)
39+
546.504
40+
>>> celsius_to_kelvin(273.354, 0)
41+
547.0
3442
>>> celsius_to_kelvin(0)
3543
273.15
3644
>>> celsius_to_kelvin(20.0)
@@ -51,6 +59,10 @@ def celsius_to_rankine(celsius: float, ndigits: int = 2) -> float:
5159
Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
5260
Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
5361
62+
>>> celsius_to_rankine(273.354, 3)
63+
983.707
64+
>>> celsius_to_rankine(273.354, 0)
65+
984.0
5466
>>> celsius_to_rankine(0)
5567
491.67
5668
>>> celsius_to_rankine(20.0)
@@ -71,6 +83,10 @@ def fahrenheit_to_celsius(fahrenheit: float, ndigits: int = 2) -> float:
7183
Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
7284
Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
7385
86+
>>> fahrenheit_to_celsius(273.354, 3)
87+
134.086
88+
>>> fahrenheit_to_celsius(273.354, 0)
89+
134.0
7490
>>> fahrenheit_to_celsius(0)
7591
-17.78
7692
>>> fahrenheit_to_celsius(20.0)
@@ -97,6 +113,10 @@ def fahrenheit_to_kelvin(fahrenheit: float, ndigits: int = 2) -> float:
97113
Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
98114
Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
99115
116+
>>> fahrenheit_to_kelvin(273.354, 3)
117+
407.236
118+
>>> fahrenheit_to_kelvin(273.354, 0)
119+
407.0
100120
>>> fahrenheit_to_kelvin(0)
101121
255.37
102122
>>> fahrenheit_to_kelvin(20.0)
@@ -123,6 +143,10 @@ def fahrenheit_to_rankine(fahrenheit: float, ndigits: int = 2) -> float:
123143
Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
124144
Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
125145
146+
>>> fahrenheit_to_rankine(273.354, 3)
147+
733.024
148+
>>> fahrenheit_to_rankine(273.354, 0)
149+
733.0
126150
>>> fahrenheit_to_rankine(0)
127151
459.67
128152
>>> fahrenheit_to_rankine(20.0)
@@ -149,6 +173,10 @@ def kelvin_to_celsius(kelvin: float, ndigits: int = 2) -> float:
149173
Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
150174
Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
151175
176+
>>> kelvin_to_celsius(273.354, 3)
177+
0.204
178+
>>> kelvin_to_celsius(273.354, 0)
179+
0.0
152180
>>> kelvin_to_celsius(273.15)
153181
0.0
154182
>>> kelvin_to_celsius(300)
@@ -169,6 +197,10 @@ def kelvin_to_fahrenheit(kelvin: float, ndigits: int = 2) -> float:
169197
Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
170198
Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
171199
200+
>>> kelvin_to_fahrenheit(273.354, 3)
201+
32.367
202+
>>> kelvin_to_fahrenheit(273.354, 0)
203+
32.0
172204
>>> kelvin_to_fahrenheit(273.15)
173205
32.0
174206
>>> kelvin_to_fahrenheit(300)
@@ -189,6 +221,10 @@ def kelvin_to_rankine(kelvin: float, ndigits: int = 2) -> float:
189221
Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
190222
Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
191223
224+
>>> kelvin_to_rankine(273.354, 3)
225+
492.037
226+
>>> kelvin_to_rankine(273.354, 0)
227+
492.0
192228
>>> kelvin_to_rankine(0)
193229
0.0
194230
>>> kelvin_to_rankine(20.0)
@@ -209,6 +245,10 @@ def rankine_to_celsius(rankine: float, ndigits: int = 2) -> float:
209245
Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
210246
Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
211247
248+
>>> rankine_to_celsius(273.354, 3)
249+
-121.287
250+
>>> rankine_to_celsius(273.354, 0)
251+
-121.0
212252
>>> rankine_to_celsius(273.15)
213253
-121.4
214254
>>> rankine_to_celsius(300)

0 commit comments

Comments
 (0)