Cleanup
This commit is contained in:
parent
d7e2613ae2
commit
7e555cf9ab
3 changed files with 9 additions and 6 deletions
|
@ -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.")
|
||||
|
|
|
@ -57,7 +57,7 @@ class CryptoPriceTest {
|
|||
assertEquals(price.currency, "USD", "buy BTC is USD")
|
||||
assertTrue(price.amount > 0.00, "buy BTC > 0")
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Throws(CryptoException::class)
|
||||
fun testMarketPriceExceptions() {
|
||||
|
@ -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() }
|
||||
)
|
||||
|
@ -105,7 +105,7 @@ class CryptoPriceTest {
|
|||
assertFailsWith(
|
||||
message = "no base did not fail",
|
||||
exceptionClass = CryptoException::class,
|
||||
block = { json.replace("base","foo").toPrice() }
|
||||
block = { json.replace("base", "foo").toPrice() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue