##// END OF EJS Templates
push method of worker return the id of the nextRange which is canceled
push method of worker return the id of the nextRange which is canceled

File last commit:

r593:552e9eaf7536
r625:d6648352006d
Show More
TestVariable.cpp
174 lines | 7.2 KiB | text/x-c | CppLexer
Add test for cach providing methods of variable
r589 #include <Variable/Variable.h>
#include <QObject>
#include <QtTest>
#include <memory>
class TestVariable : public QObject {
Q_OBJECT
private slots:
void testNotInCacheRangeList();
void testInCacheRangeList();
};
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}};
PR: Use DateUtils instead of static_cast
r593 auto sqpR = SqpRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)};
Add test for cach providing methods of variable
r589
auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
PR: Use DateUtils instead of static_cast
r593 auto sqpCR
= SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)};
Add test for cach providing methods of variable
r589
Variable var{"Var test", sqpR};
var.setCacheRange(sqpCR);
// 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}};
PR: Use DateUtils instead of static_cast
r593 auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589
auto notInCach = var.provideNotInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 1);
auto notInCachRange = notInCach.first();
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
Add test for cach providing methods of variable
r589
// 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}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideNotInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 1);
notInCachRange = notInCach.first();
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRS));
Add test for cach providing methods of variable
r589
// 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}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideNotInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 0);
// 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}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideNotInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 1);
notInCachRange = notInCach.first();
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRE));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
Add test for cach providing methods of variable
r589
// 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}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideNotInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 1);
notInCachRange = notInCach.first();
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
Add test for cach providing methods of variable
r589
// 6: ts <varTS < varTE < te
ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideNotInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 2);
notInCachRange = notInCach.first();
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRS));
Add test for cach providing methods of variable
r589 notInCachRange = notInCach[1];
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRE));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
Add test for cach providing methods of variable
r589 }
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}};
PR: Use DateUtils instead of static_cast
r593 auto sqpR = SqpRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)};
Add test for cach providing methods of variable
r589
auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
PR: Use DateUtils instead of static_cast
r593 auto sqpCR
= SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)};
Add test for cach providing methods of variable
r589
Variable var{"Var test", sqpR};
var.setCacheRange(sqpCR);
// 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}};
PR: Use DateUtils instead of static_cast
r593 auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589
auto notInCach = var.provideInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 0);
// 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}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 1);
auto notInCachRange = notInCach.first();
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRS));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
Add test for cach providing methods of variable
r589
// 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}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 1);
notInCachRange = notInCach.first();
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
Add test for cach providing methods of variable
r589
// 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}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 1);
notInCachRange = notInCach.first();
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRE));
Add test for cach providing methods of variable
r589
// 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}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 0);
// 6: ts <varTS < varTE < te
ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
PR: Use DateUtils instead of static_cast
r593 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
Add test for cach providing methods of variable
r589 notInCach = var.provideInCacheRangeList(sqp);
QCOMPARE(notInCach.size(), 1);
notInCachRange = notInCach.first();
PR: Use DateUtils instead of static_cast
r593 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRS));
QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRE));
Add test for cach providing methods of variable
r589 }
QTEST_MAIN(TestVariable)
#include "TestVariable.moc"