[Pkg-owncloud-commits] [owncloud-client] 98/218: Utility: Fix the size display back to JEDEC standard.

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 17 14:30:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 9004fd6d11326f4a0d851f1ad27ffcab7bcf3f0d
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Sep 10 17:31:44 2015 +0200

    Utility: Fix the size display back to JEDEC standard.
    
    Also updated the test.
---
 src/libsync/utility.cpp | 13 +++++++------
 test/testutility.h      | 24 +++++++++++-------------
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/src/libsync/utility.cpp b/src/libsync/utility.cpp
index 98dc63d..4598898 100644
--- a/src/libsync/utility.cpp
+++ b/src/libsync/utility.cpp
@@ -107,21 +107,22 @@ QString Utility::octetsToString( qint64 octets )
     static const qint64 kb = THE_FACTOR;
     static const qint64 mb = THE_FACTOR * kb;
     static const qint64 gb = THE_FACTOR * mb;
-    static const qint64 tb = THE_FACTOR * gb;
 
     QString s;
     qreal value = octets;
-    if (octets >= tb) {
-        s = QCoreApplication::translate("Utility", "%L1 TB");
-        value /= tb;
-    } else if (octets >= gb) {
+
+    // do not display terra byte with the current units, as when
+    // the MB, GB and KB units were made, there was no TB,
+    // see the JEDEC standard
+    // https://en.wikipedia.org/wiki/JEDEC_memory_standards
+    if (octets >= gb) {
         s = QCoreApplication::translate("Utility", "%L1 GB");
         value /= gb;
     } else if (octets >= mb) {
         s = QCoreApplication::translate("Utility", "%L1 MB");
         value /= mb;
     } else if (octets >= kb) {
-        s = QCoreApplication::translate("Utility", "%L1 kB");
+        s = QCoreApplication::translate("Utility", "%L1 KB");
         value /= kb;
     } else  {
         s = QCoreApplication::translate("Utility", "%L1 B");
diff --git a/test/testutility.h b/test/testutility.h
index e88ba67..8635a98 100644
--- a/test/testutility.h
+++ b/test/testutility.h
@@ -30,26 +30,24 @@ private slots:
     {
         QLocale::setDefault(QLocale("en"));
         QCOMPARE(octetsToString(999) , QString("999 B"));
-        QCOMPARE(octetsToString(1024) , QString("1 kB"));
-        QCOMPARE(octetsToString(1110) , QString("1.1 kB"));
+        QCOMPARE(octetsToString(1024) , QString("1 KB"));
+        QCOMPARE(octetsToString(1364) , QString("1.3 KB"));
 
-        QCOMPARE(octetsToString(9110) , QString("9.1 kB"));
-        QCOMPARE(octetsToString(9910) , QString("9.9 kB"));
-        QCOMPARE(octetsToString(9999) , QString("10 kB"));
-        QCOMPARE(octetsToString(10240) , QString("10 kB"));
+        QCOMPARE(octetsToString(9110) , QString("8.9 KB"));
+        QCOMPARE(octetsToString(9910) , QString("9.7 KB"));
+        QCOMPARE(octetsToString(10240) , QString("10 KB"));
 
-        QCOMPARE(octetsToString(123456) , QString("123 kB"));
+        QCOMPARE(octetsToString(123456) , QString("121 KB"));
         QCOMPARE(octetsToString(1234567) , QString("1.2 MB"));
         QCOMPARE(octetsToString(12345678) , QString("12 MB"));
-        QCOMPARE(octetsToString(123456789) , QString("123 MB"));
-        QCOMPARE(octetsToString(1000LL*1000*1000 * 5) , QString("5 GB"));
+        QCOMPARE(octetsToString(123456789) , QString("118 MB"));
+        QCOMPARE(octetsToString(1000LL*1000*1000 * 5) , QString("4.7 GB"));
 
         QCOMPARE(octetsToString(1), QString("1 B"));
         QCOMPARE(octetsToString(2), QString("2 B"));
-        QCOMPARE(octetsToString(1000), QString("1 kB"));
-        QCOMPARE(octetsToString(1000*1000), QString("1 MB"));
-        QCOMPARE(octetsToString(1000LL*1000*1000), QString("1 GB"));
-        QCOMPARE(octetsToString(1000LL*1000*1000*1000), QString("1 TB"));
+        QCOMPARE(octetsToString(1024), QString("1 KB"));
+        QCOMPARE(octetsToString(1024*1024), QString("1 MB"));
+        QCOMPARE(octetsToString(1024LL*1024*1024), QString("1 GB"));
     }
 
     void testLaunchOnStartup()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list