##// END OF EJS Templates
Added Single Threshold cache tests cases around limits...
Added Single Threshold cache tests cases around limits Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r13:8498c2e83e63
r13:8498c2e83e63
Show More
TestVariableController2.cpp
144 lines | 4.9 KiB | text/x-c | CppLexer
/ tests / Variable / TestVariableController2.cpp
Basic serial variable creation and update...
r2 #include <cmath>
VariableController2 tests refactoring...
r3 #include <algorithm>
#include <numeric>
First init from SciQLop Core module...
r0 #include <QtTest>
#include <QObject>
Basic serial variable creation and update...
r2 #include <Variable/VariableController2.h>
#include <Data/DateTimeRange.h>
#include <Data/IDataProvider.h>
#include <Data/ScalarSeries.h>
#include <Data/DataProviderParameters.h>
#include <Common/containers.h>
First init from SciQLop Core module...
r0
More VC2 tests refactoring...
r5 #include <TestUtils/TestProviders.h>
Basic serial variable creation and update...
r2
More VC2 tests refactoring...
r5 #define TEST_VC2_FIXTURE(slope) \
VariableController2 vc; \
auto provider = std::make_shared<SimpleRange<slope>>();\
Basic serial variable creation and update...
r2
More VC2 tests refactoring...
r5 #define TEST_VC2_CREATE_DEFAULT_VAR(name)\
auto range = DateTimeRange::fromDateTime(QDate(2018,8,7),QTime(14,00),\
QDate(2018,8,7),QTime(16,00));\
auto name = vc.createVariable("name", {}, provider, range);\
Basic serial variable creation and update...
r2
Added basic cache tests for new VC...
r11 Q_DECLARE_METATYPE(DateTimeRangeTransformation);
Basic serial variable creation and update...
r2
class TestVariableController2 : public QObject
First init from SciQLop Core module...
r0 {
Q_OBJECT
public:
explicit TestVariableController2(QObject *parent = nullptr) : QObject(parent){}
signals:
private slots:
void initTestCase(){}
void cleanupTestCase(){}
Basic serial variable creation and update...
r2 void testCreateVariable()
{
More VC2 tests refactoring...
r5 TEST_VC2_FIXTURE(2);
Many fixes plus implemented var synchronization...
r9 auto range = DateTimeRange::fromDateTime(QDate(2018,8,7),QTime(14,00),
QDate(2018,8,7),QTime(16,00));
Basic serial variable creation and update...
r2 bool callbackCalled = false;
connect(&vc,&VariableController2::variableAdded, [&callbackCalled](std::shared_ptr<Variable>){callbackCalled=true;});
QVERIFY(!callbackCalled);
Many fixes plus implemented var synchronization...
r9 auto var1 = vc.createVariable("var1", {}, provider, range);
Basic serial variable creation and update...
r2 QVERIFY(SciQLop::containers::contains(vc.variables(), var1));
QVERIFY(callbackCalled);
}
void testDeleteVariable()
{
More VC2 tests refactoring...
r5 TEST_VC2_FIXTURE(1);
Many fixes plus implemented var synchronization...
r9 auto range = DateTimeRange::fromDateTime(QDate(2018,8,7),QTime(14,00),
QDate(2018,8,7),QTime(16,00));
Basic serial variable creation and update...
r2 bool callbackCalled = false;
connect(&vc,&VariableController2::variableDeleted, [&callbackCalled](std::shared_ptr<Variable>){callbackCalled=true;});
Many fixes plus implemented var synchronization...
r9 auto var1 = vc.createVariable("var1", {}, provider, range);
Basic serial variable creation and update...
r2 QVERIFY(SciQLop::containers::contains(vc.variables(), var1));
QVERIFY(!callbackCalled);
vc.deleteVariable(var1);
QVERIFY(!SciQLop::containers::contains(vc.variables(), var1));
QVERIFY(callbackCalled);
}
void testGetData()
First init from SciQLop Core module...
r0 {
More VC2 tests refactoring...
r5 TEST_VC2_FIXTURE(10);
TEST_VC2_CREATE_DEFAULT_VAR(var1);
Introduced opaque library from Kyle Markley and improved DateTimeRange...
r4 check_variable_state<RangeType<10>>(var1, range);
}
More VC2 tests refactoring...
r5 void testZoom_data()
Introduced opaque library from Kyle Markley and improved DateTimeRange...
r4 {
More VC2 tests refactoring...
r5 QTest::addColumn<double>("zoom");
QTest::newRow("Zoom IN 10x") << .1;
QTest::newRow("Zoom OUT 10x") << 10.;
QTest::newRow("Zoom IN 1x") << 1.;
}
void testZoom()
{
TEST_VC2_FIXTURE(100);
TEST_VC2_CREATE_DEFAULT_VAR(var1);
check_variable_state<RangeType<100>>(var1, range);
Introduced opaque library from Kyle Markley and improved DateTimeRange...
r4
More VC2 tests refactoring...
r5 QFETCH(double, zoom);
range *=zoom;
Introduced opaque library from Kyle Markley and improved DateTimeRange...
r4 vc.changeRange(var1, range);
More VC2 tests refactoring...
r5 check_variable_state<RangeType<100>>(var1, range);
Introduced opaque library from Kyle Markley and improved DateTimeRange...
r4 }
More VC2 tests refactoring...
r5 void testPan_data()
Introduced opaque library from Kyle Markley and improved DateTimeRange...
r4 {
More VC2 tests refactoring...
r5 QTest::addColumn<double>("pan");
QTest::newRow("Right 1000 seconds") << 1000.;
QTest::newRow("Left 1000 seconds") << -1000.;
QTest::newRow("Right 0.1 seconds") << .1;
QTest::newRow("Left 0.1 seconds") << -.1;
}
void testPan()
{
TEST_VC2_FIXTURE(10);
TEST_VC2_CREATE_DEFAULT_VAR(var1);
Introduced opaque library from Kyle Markley and improved DateTimeRange...
r4 check_variable_state<RangeType<10>>(var1, range);
More VC2 tests refactoring...
r5 QFETCH(double, pan);
range += Seconds<double>{pan};
Introduced opaque library from Kyle Markley and improved DateTimeRange...
r4 vc.changeRange(var1, range);
check_variable_state<RangeType<10>>(var1, range);
First init from SciQLop Core module...
r0 }
Added basic cache tests for new VC...
r11 void testCache_data()
{
QTest::addColumn<DateTimeRangeTransformation>("transformation");
QTest::addColumn<int>("expectedIncrement");
QTest::newRow("zoom in") << DateTimeRangeTransformation{0.8,Seconds<double>(0.)} << 0;
QTest::newRow("tiny zoom out") << DateTimeRangeTransformation{1.01,Seconds<double>(0.)} << 0;
Added Single Threshold cache tests cases around limits...
r13 QTest::newRow("just under cache zoom out") << DateTimeRangeTransformation{2.0/1.1,Seconds<double>(0.)} << 0;
QTest::newRow("just over cache zoom out") << DateTimeRangeTransformation{2.001/1.1, Seconds<double>(0.)} << 2;
Added basic cache tests for new VC...
r11 QTest::newRow("tiny pan left") << DateTimeRangeTransformation{1.,Seconds<double>(-100.)} << 0;
QTest::newRow("tiny pan right") << DateTimeRangeTransformation{1.,Seconds<double>(100.)} << 0;
}
void testCache()
{
TEST_VC2_FIXTURE(10);
TEST_VC2_CREATE_DEFAULT_VAR(var1);
check_variable_state<RangeType<10>>(var1, range);
QFETCH(DateTimeRangeTransformation, transformation);
QFETCH(int, expectedIncrement);
auto initialCount = provider->callCounter;
range = range.transform(transformation);
vc.changeRange(var1, range);
check_variable_state<RangeType<10>>(var1, range);
QCOMPARE(provider->callCounter-initialCount, expectedIncrement);
}
First init from SciQLop Core module...
r0 };
QTEST_MAIN(TestVariableController2)
#include "TestVariableController2.moc"