[Pkg-owncloud-commits] [owncloud-client] 42/470: Tests: Add a test for the timeAgoInWords function

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu May 12 16:24:42 UTC 2016


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 e846b36bf6579647b636e627337ba1020aa17c89
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Mon Feb 15 17:59:01 2016 +0100

    Tests: Add a test for the timeAgoInWords function
---
 test/testutility.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/test/testutility.h b/test/testutility.h
index 8635a98..e8ce075 100644
--- a/test/testutility.h
+++ b/test/testutility.h
@@ -118,6 +118,38 @@ private slots:
 	    QVERIFY( versionOfInstalledBinary().isEmpty());
 	}
     }
+
+    void testTimeAgo()
+    {
+        // Both times in local time
+        QDateTime d1 = QDateTime::fromString("2015-01-24T09:20:30+01:00", Qt::ISODate);
+        QDateTime d2 = QDateTime::fromString("2015-01-23T09:20:30+01:00", Qt::ISODate);
+        QString s = timeAgoInWords(d2, d1);
+        QCOMPARE(s, QLatin1String("1 day(s) ago"));
+
+        //
+        QDateTime earlyTS = QDateTime::fromString("2015-01-24T09:20:30+01:00", Qt::ISODate);
+        earlyTS.setTimeSpec(Qt::UTC);
+        QDateTime laterTS = earlyTS.toOffsetFromUtc(3600);
+        laterTS.setTimeSpec(Qt::UTC);
+        s = timeAgoInWords(earlyTS, laterTS);
+        QCOMPARE(s, QLatin1String("1 hour(s) ago"));
+
+        earlyTS = QDateTime::currentDateTime();
+
+        laterTS.setTimeSpec(Qt::LocalTime);
+        laterTS.setTimeZone( QTimeZone("Pacific/Easter") );
+        laterTS = earlyTS;
+
+        s = timeAgoInWords(earlyTS, laterTS );
+        QCOMPARE(s, QLatin1String("now"));
+
+        earlyTS = earlyTS.addSecs(-6);
+        s = timeAgoInWords(earlyTS, laterTS );
+        QCOMPARE(s, QLatin1String("Less than a minute ago"));
+
+
+    }
 };
 
 #endif

-- 
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