diff --git a/core/tests/Variable/TestVariable.cpp b/core/tests/Variable/TestVariable.cpp index 1228ddc..3fb2623 100644 --- a/core/tests/Variable/TestVariable.cpp +++ b/core/tests/Variable/TestVariable.cpp @@ -20,13 +20,12 @@ void TestVariable::testNotInCacheRangeList() auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}}; - auto sqpR = SqpRange{static_cast(varRS.toMSecsSinceEpoch()), - static_cast(varRE.toMSecsSinceEpoch())}; + auto sqpR = SqpRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)}; auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; - auto sqpCR = SqpRange{static_cast(varCRS.toMSecsSinceEpoch()), - static_cast(varCRE.toMSecsSinceEpoch())}; + auto sqpCR + = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; Variable var{"Var test", sqpR}; var.setCacheRange(sqpCR); @@ -34,8 +33,7 @@ void TestVariable::testNotInCacheRangeList() // 1: [ts,te] < varTS auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; - auto sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; auto notInCach = var.provideNotInCacheRangeList(sqp); @@ -43,25 +41,23 @@ void TestVariable::testNotInCacheRangeList() auto notInCachRange = notInCach.first(); - QCOMPARE(notInCachRange.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 2: ts < varTS < te < varTE ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideNotInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 1); notInCachRange = notInCach.first(); - QCOMPARE(notInCachRange.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(varCRS.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRS)); // 3: varTS < ts < te < varTE ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideNotInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 0); @@ -69,38 +65,35 @@ void TestVariable::testNotInCacheRangeList() // 4: varTS < ts < varTE < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideNotInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 1); notInCachRange = notInCach.first(); - QCOMPARE(notInCachRange.m_TStart, static_cast(varCRE.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRE)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 5: varTS < varTE < ts < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideNotInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 1); notInCachRange = notInCach.first(); - QCOMPARE(notInCachRange.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 6: ts (ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideNotInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 2); notInCachRange = notInCach.first(); - QCOMPARE(notInCachRange.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(varCRS.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRS)); notInCachRange = notInCach[1]; - QCOMPARE(notInCachRange.m_TStart, static_cast(varCRE.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRE)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); } @@ -109,13 +102,12 @@ void TestVariable::testInCacheRangeList() auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}}; - auto sqpR = SqpRange{static_cast(varRS.toMSecsSinceEpoch()), - static_cast(varRE.toMSecsSinceEpoch())}; + auto sqpR = SqpRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)}; auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; - auto sqpCR = SqpRange{static_cast(varCRS.toMSecsSinceEpoch()), - static_cast(varCRE.toMSecsSinceEpoch())}; + auto sqpCR + = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; Variable var{"Var test", sqpR}; var.setCacheRange(sqpCR); @@ -123,8 +115,7 @@ void TestVariable::testInCacheRangeList() // 1: [ts,te] < varTS auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; - auto sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; auto notInCach = var.provideInCacheRangeList(sqp); @@ -133,54 +124,49 @@ void TestVariable::testInCacheRangeList() // 2: ts < varTS < te < varTE ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 1); auto notInCachRange = notInCach.first(); - QCOMPARE(notInCachRange.m_TStart, static_cast(varCRS.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRS)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 3: varTS < ts < te < varTE ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 1); notInCachRange = notInCach.first(); - QCOMPARE(notInCachRange.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 4: varTS < ts < varTE < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 1); notInCachRange = notInCach.first(); - QCOMPARE(notInCachRange.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(varCRE.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRE)); // 5: varTS < varTE < ts < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 0); // 6: ts (ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = var.provideInCacheRangeList(sqp); QCOMPARE(notInCach.size(), 1); notInCachRange = notInCach.first(); - QCOMPARE(notInCachRange.m_TStart, static_cast(varCRS.toMSecsSinceEpoch())); - QCOMPARE(notInCachRange.m_TEnd, static_cast(varCRE.toMSecsSinceEpoch())); + QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRS)); + QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRE)); } diff --git a/core/tests/Variable/TestVariableCacheController.cpp b/core/tests/Variable/TestVariableCacheController.cpp index a46dd04..326410b 100644 --- a/core/tests/Variable/TestVariableCacheController.cpp +++ b/core/tests/Variable/TestVariableCacheController.cpp @@ -22,18 +22,15 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; - auto sqp0 = SqpRange{static_cast(ts0.toMSecsSinceEpoch()), - static_cast(te0.toMSecsSinceEpoch())}; + auto sqp0 = SqpRange{DateUtils::secondsSinceEpoch(ts0), DateUtils::secondsSinceEpoch(te0)}; auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}}; - auto sqp1 = SqpRange{static_cast(ts1.toMSecsSinceEpoch()), - static_cast(te1.toMSecsSinceEpoch())}; + auto sqp1 = SqpRange{DateUtils::secondsSinceEpoch(ts1), DateUtils::secondsSinceEpoch(te1)}; auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}}; auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; - auto sqp2 = SqpRange{static_cast(ts2.toMSecsSinceEpoch()), - static_cast(te2.toMSecsSinceEpoch())}; + auto sqp2 = SqpRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)}; auto var0 = std::make_shared("", sqp0); @@ -44,210 +41,197 @@ void TestVariableCacheController::testProvideNotInCacheDateTimeList() // first case [ts,te] < ts0 auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; - auto sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); auto notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); // second case ts < ts0 && ts0 < te <= te0 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0)); // 3th case ts < ts0 && te0 < te <= ts1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 2); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0)); notInCacheSqp = notInCach.at(1); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 4th case ts < ts0 && ts1 < te <= te1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 2); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0)); notInCacheSqp = notInCach.at(1); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); // 5th case ts < ts0 && te3 < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 4); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts0.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0)); notInCacheSqp = notInCach.at(1); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); notInCacheSqp = notInCach.at(2); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te1.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts2.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te1)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts2)); notInCacheSqp = notInCach.at(3); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te2.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te2)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 6th case ts2 < ts ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 45, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 7th case ts = te0 && te < ts1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 8th case ts0 < ts < te0 && te < ts1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 9th case ts0 < ts < te0 && ts1 < te < te1 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te0.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); // 10th case te1 < ts < te < ts2 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 1); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 11th case te0 < ts < ts1 && te3 < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 3); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); notInCacheSqp = notInCach.at(1); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te1.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts2.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te1)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts2)); notInCacheSqp = notInCach.at(2); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te2.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te2)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 12th case te0 < ts < ts1 && te3 < te ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 2); notInCacheSqp = notInCach.first(); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(ts.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(ts1.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); notInCacheSqp = notInCach.at(1); - QCOMPARE(notInCacheSqp.m_TStart, static_cast(te1.toMSecsSinceEpoch())); - QCOMPARE(notInCacheSqp.m_TEnd, static_cast(te.toMSecsSinceEpoch())); + QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te1)); + QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); // 12th case ts0 < ts < te0 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 10, 0}}; te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 50, 0}}; - sqp = SqpRange{static_cast(ts.toMSecsSinceEpoch()), - static_cast(te.toMSecsSinceEpoch())}; + sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); QCOMPARE(notInCach.size(), 0); @@ -260,33 +244,27 @@ void TestVariableCacheController::testAddDateTime() auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; - auto sqp0 = SqpRange{static_cast(ts0.toMSecsSinceEpoch()), - static_cast(te0.toMSecsSinceEpoch())}; + auto sqp0 = SqpRange{DateUtils::secondsSinceEpoch(ts0), DateUtils::secondsSinceEpoch(te0)}; auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}}; - auto sqp1 = SqpRange{static_cast(ts1.toMSecsSinceEpoch()), - static_cast(te1.toMSecsSinceEpoch())}; + auto sqp1 = SqpRange{DateUtils::secondsSinceEpoch(ts1), DateUtils::secondsSinceEpoch(te1)}; auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}}; auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; - auto sqp2 = SqpRange{static_cast(ts2.toMSecsSinceEpoch()), - static_cast(te2.toMSecsSinceEpoch())}; + auto sqp2 = SqpRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)}; auto ts01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; auto te01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; - auto sqp01 = SqpRange{static_cast(ts01.toMSecsSinceEpoch()), - static_cast(te01.toMSecsSinceEpoch())}; + auto sqp01 = SqpRange{DateUtils::secondsSinceEpoch(ts01), DateUtils::secondsSinceEpoch(te01)}; auto ts3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 14, 0, 0}}; auto te3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 16, 0, 0}}; - auto sqp3 = SqpRange{static_cast(ts3.toMSecsSinceEpoch()), - static_cast(te3.toMSecsSinceEpoch())}; + auto sqp3 = SqpRange{DateUtils::secondsSinceEpoch(ts3), DateUtils::secondsSinceEpoch(te3)}; auto ts03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; auto te03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}}; - auto sqp03 = SqpRange{static_cast(ts03.toMSecsSinceEpoch()), - static_cast(te03.toMSecsSinceEpoch())}; + auto sqp03 = SqpRange{DateUtils::secondsSinceEpoch(ts03), DateUtils::secondsSinceEpoch(te03)}; auto var0 = std::make_shared("", sqp0); @@ -297,28 +275,28 @@ void TestVariableCacheController::testAddDateTime() auto dateCacheList = variableCacheController.dateCacheList(var0); QCOMPARE(dateCacheList.count(), 1); auto dateCache = dateCacheList.at(0); - QCOMPARE(dateCache.m_TStart, static_cast(ts0.toMSecsSinceEpoch())); - QCOMPARE(dateCache.m_TEnd, static_cast(te0.toMSecsSinceEpoch())); + QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); + QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te0)); // 2nd case: add a second interval : sqp1 > sqp0 variableCacheController.addDateTime(var0, sqp1); dateCacheList = variableCacheController.dateCacheList(var0); QCOMPARE(dateCacheList.count(), 2); dateCache = dateCacheList.at(0); - QCOMPARE(dateCache.m_TStart, static_cast(ts0.toMSecsSinceEpoch())); - QCOMPARE(dateCache.m_TEnd, static_cast(te0.toMSecsSinceEpoch())); + QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); + QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te0)); dateCache = dateCacheList.at(1); - QCOMPARE(dateCache.m_TStart, static_cast(ts1.toMSecsSinceEpoch())); - QCOMPARE(dateCache.m_TEnd, static_cast(te1.toMSecsSinceEpoch())); + QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts1)); + QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te1)); // 3th case: merge sqp0 & sqp1 with sqp01 variableCacheController.addDateTime(var0, sqp01); dateCacheList = variableCacheController.dateCacheList(var0); QCOMPARE(dateCacheList.count(), 1); dateCache = dateCacheList.at(0); - QCOMPARE(dateCache.m_TStart, static_cast(ts0.toMSecsSinceEpoch())); - QCOMPARE(dateCache.m_TEnd, static_cast(te1.toMSecsSinceEpoch())); + QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); + QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te1)); // 4th case: add a second interval : sqp1 > sqp0 @@ -327,16 +305,16 @@ void TestVariableCacheController::testAddDateTime() dateCacheList = variableCacheController.dateCacheList(var0); QCOMPARE(dateCacheList.count(), 3); dateCache = dateCacheList.at(0); - QCOMPARE(dateCache.m_TStart, static_cast(ts0.toMSecsSinceEpoch())); - QCOMPARE(dateCache.m_TEnd, static_cast(te1.toMSecsSinceEpoch())); + QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); + QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te1)); dateCache = dateCacheList.at(1); - QCOMPARE(dateCache.m_TStart, static_cast(ts3.toMSecsSinceEpoch())); - QCOMPARE(dateCache.m_TEnd, static_cast(te3.toMSecsSinceEpoch())); + QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts3)); + QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te3)); dateCache = dateCacheList.at(2); - QCOMPARE(dateCache.m_TStart, static_cast(ts2.toMSecsSinceEpoch())); - QCOMPARE(dateCache.m_TEnd, static_cast(te2.toMSecsSinceEpoch())); + QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts2)); + QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te2)); // 5th case: merge all interval @@ -344,8 +322,8 @@ void TestVariableCacheController::testAddDateTime() dateCacheList = variableCacheController.dateCacheList(var0); QCOMPARE(dateCacheList.count(), 1); dateCache = dateCacheList.at(0); - QCOMPARE(dateCache.m_TStart, static_cast(ts0.toMSecsSinceEpoch())); - QCOMPARE(dateCache.m_TEnd, static_cast(te03.toMSecsSinceEpoch())); + QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); + QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te03)); }