##// END OF EJS Templates
Fixed all tests \o/ with new TS impl...
Fixed all tests \o/ with new TS impl Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r68:ae48b1783344
r68:ae48b1783344
Show More
TestProviders.h
71 lines | 1.9 KiB | text/x-c | CLexer
More VC2 tests refactoring...
r5 #ifndef TESTPROVIDER_H
#define TESTPROVIDER_H
#include <Data/DataProviderParameters.h>
#include <Data/DataSeries.h>
Switched to new TS impl, but quite broken!...
r67 #include <Data/IDataProvider.h>
More VC2 tests refactoring...
r5 #include <Data/ScalarSeries.h>
Switched to new TS impl, but quite broken!...
r67 #include <Data/ScalarTimeSerie.h>
#include <QUuid>
#include <QtGlobal>
#include <QtTest>
#include <TimeSeries.h>
#include <Variable/Variable2.h>
#include <algorithm>
#include <cmath>
#include <memory>
#include <numeric>
More VC2 tests refactoring...
r5
Switched to new TS impl, but quite broken!...
r67 template<int slope> class SimpleRange : public IDataProvider
More VC2 tests refactoring...
r5 {
public:
Switched to new TS impl, but quite broken!...
r67 SimpleRange() = default;
More VC2 tests refactoring...
r5
Switched to new TS impl, but quite broken!...
r67 int callCounter = 0;
std::shared_ptr<IDataProvider> clone() const override
{
return std::make_shared<SimpleRange>();
}
More VC2 tests refactoring...
r5
Switched to new TS impl, but quite broken!...
r67 TimeSeries::ITimeSerie*
getData(const DataProviderParameters& parameters) override
{
callCounter += 1;
std::size_t size =
static_cast<std::size_t>(floor(parameters.m_Range.m_TEnd) -
ceil(parameters.m_Range.m_TStart) + 1.);
auto serie = new ScalarTimeSerie(size);
std::generate(std::begin(*serie), std::end(*serie),
[i = ceil(parameters.m_Range.m_TStart)]() mutable {
Fixed all tests \o/ with new TS impl...
r68 return std::pair<double, double>{i, i++ * slope};
Switched to new TS impl, but quite broken!...
r67 });
return serie;
}
More VC2 tests refactoring...
r5 };
Switched to new TS impl, but quite broken!...
r67 template<class T> auto sumdiff(T begin, T end)
More VC2 tests refactoring...
r5 {
Switched to new TS impl, but quite broken!...
r67 std::vector<double> diff_vect(end - begin - 1);
auto diff = [](auto next, auto item) { return next.value() - item.value(); };
std::transform(begin + 1, end, begin, diff_vect.begin(), diff);
return std::accumulate(diff_vect.cbegin(), diff_vect.cend(), 0);
More VC2 tests refactoring...
r5 }
Switched to new TS impl, but quite broken!...
r67 template<int slope = 1> struct RangeType
More VC2 tests refactoring...
r5 {
Switched to new TS impl, but quite broken!...
r67 static void check_properties(std::shared_ptr<Variable2> v, DateTimeRange r)
{
// TODO
}
More VC2 tests refactoring...
r5 };
Switched to new TS impl, but quite broken!...
r67 template<class T>
void check_variable_state(std::shared_ptr<Variable2> v, DateTimeRange r)
More VC2 tests refactoring...
r5 {
Fixed all tests \o/ with new TS impl...
r68 auto range = v->data()->axis_range(0);
QVERIFY(range.first >= r.m_TStart);
QVERIFY(range.second <= r.m_TEnd);
Switched to new TS impl, but quite broken!...
r67 T::check_properties(v, r);
More VC2 tests refactoring...
r5 }
#endif