mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Add BTC prefix or postfix to Price.toFriendlyString method
This commit is contained in:
parent
591d68a6fd
commit
bf2ca1fc0c
2 changed files with 12 additions and 10 deletions
|
@ -129,7 +129,9 @@ public class Price extends MonetaryWrapper implements Comparable<Price> {
|
|||
}
|
||||
|
||||
public String toFriendlyString() {
|
||||
return monetary instanceof Altcoin ? ((Altcoin) monetary).toFriendlyString() : ((Fiat) monetary).toFriendlyString();
|
||||
return monetary instanceof Altcoin ?
|
||||
((Altcoin) monetary).toFriendlyString() + "/BTC" :
|
||||
((Fiat) monetary).toFriendlyString().replace(((Fiat) monetary).currencyCode, "") + "BTC/" + ((Fiat) monetary).currencyCode;
|
||||
}
|
||||
|
||||
public String toPlainString() {
|
||||
|
|
|
@ -27,14 +27,14 @@ public class PriceTest {
|
|||
Price result = Price.parse("USD", "0.1");
|
||||
Assert.assertEquals(
|
||||
"Fiat value should be formatted with two decimals.",
|
||||
"0.10 USD",
|
||||
"0.10 BTC/USD",
|
||||
result.toFriendlyString()
|
||||
);
|
||||
|
||||
result = Price.parse("EUR", "0.1234");
|
||||
Assert.assertEquals(
|
||||
"Fiat value should be given two decimals",
|
||||
"0.1234 EUR",
|
||||
"0.1234 BTC/EUR",
|
||||
result.toFriendlyString()
|
||||
);
|
||||
|
||||
|
@ -57,19 +57,19 @@ public class PriceTest {
|
|||
|
||||
Assert.assertEquals(
|
||||
"Comma (',') as decimal separator should be converted to period ('.')",
|
||||
"0.0001 USD",
|
||||
"0.0001 BTC/USD",
|
||||
Price.parse("USD", "0,0001").toFriendlyString()
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Too many decimals should get rounded up properly.",
|
||||
"10000.2346 LTC",
|
||||
"10000.2346 LTC/BTC",
|
||||
Price.parse("LTC", "10000,23456789").toFriendlyString()
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Too many decimals should get rounded down properly.",
|
||||
"10000.2345 LTC",
|
||||
"10000.2345 LTC/BTC",
|
||||
Price.parse("LTC", "10000,23454999").toFriendlyString()
|
||||
);
|
||||
|
||||
|
@ -95,14 +95,14 @@ public class PriceTest {
|
|||
Price result = Price.valueOf("USD", 1);
|
||||
Assert.assertEquals(
|
||||
"Fiat value should have four decimals.",
|
||||
"0.0001 USD",
|
||||
"0.0001 BTC/USD",
|
||||
result.toFriendlyString()
|
||||
);
|
||||
|
||||
result = Price.valueOf("EUR", 1234);
|
||||
Assert.assertEquals(
|
||||
"Fiat value should be given two decimals",
|
||||
"0.1234 EUR",
|
||||
"0.1234 BTC/EUR",
|
||||
result.toFriendlyString()
|
||||
);
|
||||
|
||||
|
@ -114,13 +114,13 @@ public class PriceTest {
|
|||
|
||||
Assert.assertEquals(
|
||||
"Too many decimals should get rounded up properly.",
|
||||
"10000.2346 LTC",
|
||||
"10000.2346 LTC/BTC",
|
||||
Price.valueOf("LTC", 1000023456789L).toFriendlyString()
|
||||
);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Too many decimals should get rounded down properly.",
|
||||
"10000.2345 LTC",
|
||||
"10000.2345 LTC/BTC",
|
||||
Price.valueOf("LTC", 1000023454999L).toFriendlyString()
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue