Changed decimal formatting
This commit is contained in:
parent
b562b674a7
commit
5a3b1d3f19
2 changed files with 4 additions and 4 deletions
|
@ -133,7 +133,7 @@ class CurrencyConverter : AbstractModule() {
|
|||
private val SYMBOLS: TreeMap<String, String> = TreeMap()
|
||||
|
||||
// Decimal format
|
||||
private val DECIMAL_FORMAT = DecimalFormat("0.00")
|
||||
private val DECIMAL_FORMAT = DecimalFormat("0.00#")
|
||||
|
||||
/**
|
||||
* Converts from a currency to another.
|
||||
|
|
|
@ -64,15 +64,15 @@ class CurrencyConverterTest: LocalProperties() {
|
|||
assertThat(
|
||||
convertCurrency(apiKey,"100 USD to EUR").msg,
|
||||
"convertCurrency(100 USD to EUR)"
|
||||
).matches("100 United States Dollar = \\d{2,3}\\.\\d+ Euro".toRegex())
|
||||
).matches("100 United States Dollar = \\d{2,3}\\.\\d{2,3} Euro".toRegex())
|
||||
assertThat(
|
||||
convertCurrency(apiKey,"1 USD to GBP").msg,
|
||||
"convertCurrency(1 USD to BGP)"
|
||||
).matches("1 United States Dollar = 0\\.\\d+ Pound Sterling".toRegex())
|
||||
).matches("1 United States Dollar = 0\\.\\d{2,3} Pound Sterling".toRegex())
|
||||
assertThat(
|
||||
convertCurrency(apiKey,"100,000.00 CAD to USD").msg,
|
||||
"convertCurrency(100,000.00 GBP to USD)"
|
||||
).matches("100,000.00 Canadian Dollar = \\d+\\.\\d+ United States Dollar".toRegex())
|
||||
).matches("100,000.00 Canadian Dollar = \\d+\\.\\d{2,3} United States Dollar".toRegex())
|
||||
assertThat(convertCurrency(apiKey,"100 USD to USD"), "convertCurrency(100 USD to USD)").all {
|
||||
prop(Message::msg).contains("You're kidding, right?")
|
||||
isInstanceOf(PublicMessage::class.java)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue