mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 11:48:56 +03:00
Utility: Use appropriate unit when converting from bytes to human readable units
We must not use the SI units if we use power of 2 I believe that we should use SI units and power of 10 But since the server still use power of 2, we need to show the same numbers But at least we use the proper standard IEC unit that are explicit
This commit is contained in:
parent
863731fd6a
commit
907b79d3b8
2 changed files with 20 additions and 20 deletions
|
@ -110,16 +110,16 @@ QString Utility::octetsToString( qint64 octets )
|
|||
QString s;
|
||||
qreal value = octets;
|
||||
if (octets >= tb) {
|
||||
s = QCoreApplication::translate("Utility", "%L1 TB");
|
||||
s = QCoreApplication::translate("Utility", "%L1 TiB");
|
||||
value /= tb;
|
||||
} else if (octets >= gb) {
|
||||
s = QCoreApplication::translate("Utility", "%L1 GB");
|
||||
s = QCoreApplication::translate("Utility", "%L1 GiB");
|
||||
value /= gb;
|
||||
} else if (octets >= mb) {
|
||||
s = QCoreApplication::translate("Utility", "%L1 MB");
|
||||
s = QCoreApplication::translate("Utility", "%L1 MiB");
|
||||
value /= mb;
|
||||
} else if (octets >= kb) {
|
||||
s = QCoreApplication::translate("Utility", "%L1 kB");
|
||||
s = QCoreApplication::translate("Utility", "%L1 KiB");
|
||||
value /= kb;
|
||||
} else {
|
||||
s = QCoreApplication::translate("Utility", "%L1 B");
|
||||
|
|
|
@ -30,27 +30,27 @@ private slots:
|
|||
QCOMPARE(octetsToString(999) , QString("999 B"));
|
||||
QCOMPARE(octetsToString(1000) , QString("1,000 B"));
|
||||
QCOMPARE(octetsToString(1010) , QString("1,010 B"));
|
||||
QCOMPARE(octetsToString(1024) , QString("1 kB"));
|
||||
QCOMPARE(octetsToString(1110) , QString("1.1 kB"));
|
||||
QCOMPARE(octetsToString(1024) , QString("1 KiB"));
|
||||
QCOMPARE(octetsToString(1110) , QString("1.1 KiB"));
|
||||
|
||||
QCOMPARE(octetsToString(9110) , QString("8.9 kB"));
|
||||
QCOMPARE(octetsToString(9910) , QString("9.7 kB"));
|
||||
QCOMPARE(octetsToString(9999) , QString("9.8 kB"));
|
||||
QCOMPARE(octetsToString(10240) , QString("10 kB"));
|
||||
QCOMPARE(octetsToString(9110) , QString("8.9 KiB"));
|
||||
QCOMPARE(octetsToString(9910) , QString("9.7 KiB"));
|
||||
QCOMPARE(octetsToString(9999) , QString("9.8 KiB"));
|
||||
QCOMPARE(octetsToString(10240) , QString("10 KiB"));
|
||||
|
||||
QCOMPARE(octetsToString(123456) , QString("121 kB"));
|
||||
QCOMPARE(octetsToString(1234567) , QString("1.2 MB"));
|
||||
QCOMPARE(octetsToString(12345678) , QString("12 MB"));
|
||||
QCOMPARE(octetsToString(123456789) , QString("118 MB"));
|
||||
QCOMPARE(octetsToString(1000LL*1000*1000 * 5) , QString("4.7 GB"));
|
||||
QCOMPARE(octetsToString(1024LL*1024*1024 * 5) , QString("5 GB"));
|
||||
QCOMPARE(octetsToString(123456) , QString("121 KiB"));
|
||||
QCOMPARE(octetsToString(1234567) , QString("1.2 MiB"));
|
||||
QCOMPARE(octetsToString(12345678) , QString("12 MiB"));
|
||||
QCOMPARE(octetsToString(123456789) , QString("118 MiB"));
|
||||
QCOMPARE(octetsToString(1000LL*1000*1000 * 5) , QString("4.7 GiB"));
|
||||
QCOMPARE(octetsToString(1024LL*1024*1024 * 5) , QString("5 GiB"));
|
||||
|
||||
QCOMPARE(octetsToString(1), QString("1 B"));
|
||||
QCOMPARE(octetsToString(2), QString("2 B"));
|
||||
QCOMPARE(octetsToString(1024), QString("1 kB"));
|
||||
QCOMPARE(octetsToString(1024*1024), QString("1 MB"));
|
||||
QCOMPARE(octetsToString(1024LL*1024*1024), QString("1 GB"));
|
||||
QCOMPARE(octetsToString(1024LL*1024*1024*1024), QString("1 TB"));
|
||||
QCOMPARE(octetsToString(1024), QString("1 KiB"));
|
||||
QCOMPARE(octetsToString(1024*1024), QString("1 MiB"));
|
||||
QCOMPARE(octetsToString(1024LL*1024*1024), QString("1 GiB"));
|
||||
QCOMPARE(octetsToString(1024LL*1024*1024*1024), QString("1 TiB"));
|
||||
}
|
||||
|
||||
void testLaunchOnStartup()
|
||||
|
|
Loading…
Reference in a new issue