##// END OF EJS Templates
Fixes data loss in some cases of data recovery from the CosiunusProvider
Fixes data loss in some cases of data recovery from the CosiunusProvider

File last commit:

r756:a7f60f6512e6
r764:6fa5f5facdaa
Show More
TestVariable.cpp
177 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}};
Fix bug when creating two variables crash the app. ...
r756
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
Fix bug when creating two variables crash the app. ...
r756 Variable var{"Var test"};
var.setRange(sqpR);
Add test for cach providing methods of variable
r589 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
Fix bug when creating two variables crash the app. ...
r756 Variable var{"Var test"};
var.setRange(sqpR);
Add test for cach providing methods of variable
r589 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"