File indexing completed on 2025-01-05 04:37:32

0001 /*
0002     SPDX-FileCopyrightText: 2011 Joris Guisson <joris.guisson@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include <QtTest>
0008 #include <util/log.h>
0009 #include <utp/timevalue.h>
0010 
0011 using namespace utp;
0012 using namespace bt;
0013 
0014 class TimeValueTest : public QObject
0015 {
0016     Q_OBJECT
0017 
0018 private Q_SLOTS:
0019     void initTestCase()
0020     {
0021         bt::InitLog("timevaluetest.log");
0022     }
0023 
0024     void cleanupTestCase()
0025     {
0026     }
0027 
0028     void testTimeValue()
0029     {
0030         TimeValue a(1, 500000);
0031         TimeValue b(3, 200000);
0032 
0033         QVERIFY(b >= a);
0034         bt::Int64 diff = b - a;
0035         Out(SYS_GEN | LOG_DEBUG) << "diff = " << diff << endl;
0036         QVERIFY(b - a == 1700);
0037 
0038         QVERIFY(b >= TimeValue(3, 200000));
0039         QVERIFY(b >= TimeValue(3, 100000));
0040         QVERIFY(b <= TimeValue(3, 200000));
0041         QVERIFY(b <= TimeValue(3, 500000));
0042 
0043         QVERIFY(b < TimeValue(3, 500000));
0044         QVERIFY(b > TimeValue(3, 100000));
0045     }
0046 };
0047 
0048 QTEST_MAIN(TimeValueTest)
0049 
0050 #include "timevaluetest.moc"