This commit is contained in:
Erik C. Thauvin 2021-05-16 23:03:10 -07:00
parent d7e2613ae2
commit 7e555cf9ab
3 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,11 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173"> <code_scheme name="Project" version="173">
<JetCodeStyleSettings> <JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value />
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings> </JetCodeStyleSettings>
<codeStyleSettings language="kotlin"> <codeStyleSettings language="kotlin">

View file

@ -55,9 +55,7 @@ open class CryptoPrice(val base: String, val currency: String, val amount: Doubl
val json = JSONObject(this) val json = JSONObject(this)
if (json.has("data")) { if (json.has("data")) {
with(json.getJSONObject("data")) { with(json.getJSONObject("data")) {
return CryptoPrice( return CryptoPrice(getString("base"), getString("currency"), getString("amount").toDouble())
getString("base"), getString("currency"), getString("amount").toDouble()
)
} }
} else { } else {
throw CryptoException(message = "Missing price data.") throw CryptoException(message = "Missing price data.")

View file

@ -91,7 +91,7 @@ class CryptoPriceTest {
assertEquals(price.amount, d, "amount is 57515.69") assertEquals(price.amount, d, "amount is 57515.69")
assertFailsWith( assertFailsWith(
message = "double convertion did not fail", message = "double conversion did not fail",
exceptionClass = CryptoException::class, exceptionClass = CryptoException::class,
block = { json.replace("5", "a").toPrice() } block = { json.replace("5", "a").toPrice() }
) )