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">
<code_scheme name="Project" version="173">
<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" />
</JetCodeStyleSettings>
<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)
if (json.has("data")) {
with(json.getJSONObject("data")) {
return CryptoPrice(
getString("base"), getString("currency"), getString("amount").toDouble()
)
return CryptoPrice(getString("base"), getString("currency"), getString("amount").toDouble())
}
} else {
throw CryptoException(message = "Missing price data.")

View file

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