Skip to content

Commit b109ae6

Browse files
committed
refactor: Remove default cases for scoped enum
1 parent 834ba37 commit b109ae6

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/qt/bitcoinunits.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,60 +26,57 @@ QList<BitcoinUnit> BitcoinUnits::availableUnits()
2626

2727
QString BitcoinUnits::longName(Unit unit)
2828
{
29-
switch(unit)
30-
{
29+
switch (unit) {
3130
case Unit::BTC: return QString("BTC");
3231
case Unit::mBTC: return QString("mBTC");
3332
case Unit::uBTC: return QString::fromUtf8("µBTC (bits)");
3433
case Unit::SAT: return QString("Satoshi (sat)");
35-
default: return QString("???");
36-
}
34+
} // no default case, so the compiler can warn about missing cases
35+
assert(false);
3736
}
3837

3938
QString BitcoinUnits::shortName(Unit unit)
4039
{
41-
switch(unit)
42-
{
43-
case Unit::uBTC: return QString::fromUtf8("bits");
40+
switch (unit) {
41+
case Unit::BTC: return longName(unit);
42+
case Unit::mBTC: return longName(unit);
43+
case Unit::uBTC: return QString("bits");
4444
case Unit::SAT: return QString("sat");
45-
default: return longName(unit);
46-
}
45+
} // no default case, so the compiler can warn about missing cases
46+
assert(false);
4747
}
4848

4949
QString BitcoinUnits::description(Unit unit)
5050
{
51-
switch(unit)
52-
{
51+
switch (unit) {
5352
case Unit::BTC: return QString("Bitcoins");
5453
case Unit::mBTC: return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)");
5554
case Unit::uBTC: return QString("Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
5655
case Unit::SAT: return QString("Satoshi (sat) (1 / 100" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
57-
default: return QString("???");
58-
}
56+
} // no default case, so the compiler can warn about missing cases
57+
assert(false);
5958
}
6059

6160
qint64 BitcoinUnits::factor(Unit unit)
6261
{
63-
switch(unit)
64-
{
62+
switch (unit) {
6563
case Unit::BTC: return 100000000;
6664
case Unit::mBTC: return 100000;
6765
case Unit::uBTC: return 100;
6866
case Unit::SAT: return 1;
69-
default: return 100000000;
70-
}
67+
} // no default case, so the compiler can warn about missing cases
68+
assert(false);
7169
}
7270

7371
int BitcoinUnits::decimals(Unit unit)
7472
{
75-
switch(unit)
76-
{
73+
switch (unit) {
7774
case Unit::BTC: return 8;
7875
case Unit::mBTC: return 5;
7976
case Unit::uBTC: return 2;
8077
case Unit::SAT: return 0;
81-
default: return 0;
82-
}
78+
} // no default case, so the compiler can warn about missing cases
79+
assert(false);
8380
}
8481

8582
QString BitcoinUnits::format(Unit unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators, bool justify)

0 commit comments

Comments
 (0)