##// END OF EJS Templates
Merge pull request 231 from SCIQLOP-Initialisation develop...
perrinel -
r603:ea9f3c3ed3a9 merge
parent child
Show More
@@ -0,0 +1,82
1 #ifndef SCIQLOP_DATASERIESITERATOR_H
2 #define SCIQLOP_DATASERIESITERATOR_H
3
4 #include "CoreGlobal.h"
5
6 #include <memory>
7
8 /**
9 * @brief The DataSeriesIteratorValue class represents the current value of a data series iterator.
10 * It offers standard access methods for the data in the series (x-axis, values), but it is up to
11 * each series to define its own implementation of how to retrieve this data, by implementing the
12 * DataSeriesIteratorValue::Impl interface
13 *
14 * @sa DataSeriesIterator
15 */
16 class SCIQLOP_CORE_EXPORT DataSeriesIteratorValue {
17 public:
18 struct Impl {
19 virtual ~Impl() noexcept = default;
20 virtual std::unique_ptr<Impl> clone() const = 0;
21 virtual bool equals(const Impl &other) const = 0;
22 virtual void next() = 0;
23 virtual void prev() = 0;
24 virtual double x() const = 0;
25 virtual double value() const = 0;
26 virtual double value(int componentIndex) const = 0;
27 };
28
29 explicit DataSeriesIteratorValue(std::unique_ptr<Impl> impl);
30 DataSeriesIteratorValue(const DataSeriesIteratorValue &other);
31 DataSeriesIteratorValue(DataSeriesIteratorValue &&other) = default;
32 DataSeriesIteratorValue &operator=(DataSeriesIteratorValue other);
33
34 bool equals(const DataSeriesIteratorValue &other) const;
35
36 /// Advances to the next value
37 void next();
38 /// Moves back to the previous value
39 void prev();
40 /// Gets x-axis data
41 double x() const;
42 /// Gets value data
43 double value() const;
44 /// Gets value data depending on an index
45 double value(int componentIndex) const;
46
47 private:
48 std::unique_ptr<Impl> m_Impl;
49 };
50
51 /**
52 * @brief The DataSeriesIterator class represents an iterator used for data series. It defines all
53 * operators needed for a standard forward iterator
54 * @sa http://www.cplusplus.com/reference/iterator/
55 */
56 class SCIQLOP_CORE_EXPORT DataSeriesIterator {
57 public:
58 using iterator_category = std::forward_iterator_tag;
59 using value_type = const DataSeriesIteratorValue;
60 using difference_type = std::ptrdiff_t;
61 using pointer = value_type *;
62 using reference = value_type &;
63
64 explicit DataSeriesIterator(DataSeriesIteratorValue value);
65 virtual ~DataSeriesIterator() noexcept = default;
66 DataSeriesIterator(const DataSeriesIterator &) = default;
67 DataSeriesIterator(DataSeriesIterator &&) = default;
68 DataSeriesIterator &operator=(const DataSeriesIterator &) = default;
69 DataSeriesIterator &operator=(DataSeriesIterator &&) = default;
70
71 DataSeriesIterator &operator++();
72 DataSeriesIterator &operator--();
73 pointer operator->() const { return &m_CurrentValue; }
74 reference operator*() const { return m_CurrentValue; }
75 bool operator==(const DataSeriesIterator &other) const;
76 bool operator!=(const DataSeriesIterator &other) const;
77
78 private:
79 DataSeriesIteratorValue m_CurrentValue;
80 };
81
82 #endif // SCIQLOP_DATASERIESITERATOR_H
@@ -0,0 +1,75
1 #include "Data/DataSeriesIterator.h"
2
3 DataSeriesIteratorValue::DataSeriesIteratorValue(
4 std::unique_ptr<DataSeriesIteratorValue::Impl> impl)
5 : m_Impl{std::move(impl)}
6 {
7 }
8
9 DataSeriesIteratorValue::DataSeriesIteratorValue(const DataSeriesIteratorValue &other)
10 : m_Impl{other.m_Impl->clone()}
11 {
12 }
13
14 DataSeriesIteratorValue &DataSeriesIteratorValue::operator=(DataSeriesIteratorValue other)
15 {
16 std::swap(m_Impl, other.m_Impl);
17 return *this;
18 }
19
20 bool DataSeriesIteratorValue::equals(const DataSeriesIteratorValue &other) const
21 {
22 return m_Impl->equals(*other.m_Impl);
23 }
24
25 void DataSeriesIteratorValue::next()
26 {
27 m_Impl->next();
28 }
29
30 void DataSeriesIteratorValue::prev()
31 {
32 m_Impl->prev();
33 }
34
35 double DataSeriesIteratorValue::x() const
36 {
37 return m_Impl->x();
38 }
39
40 double DataSeriesIteratorValue::value() const
41 {
42 return m_Impl->value();
43 }
44
45 double DataSeriesIteratorValue::value(int componentIndex) const
46 {
47 return m_Impl->value(componentIndex);
48 }
49
50 DataSeriesIterator::DataSeriesIterator(DataSeriesIteratorValue value)
51 : m_CurrentValue{std::move(value)}
52 {
53 }
54
55 DataSeriesIterator &DataSeriesIterator::operator++()
56 {
57 m_CurrentValue.next();
58 return *this;
59 }
60
61 DataSeriesIterator &DataSeriesIterator::operator--()
62 {
63 m_CurrentValue.prev();
64 return *this;
65 }
66
67 bool DataSeriesIterator::operator==(const DataSeriesIterator &other) const
68 {
69 return m_CurrentValue.equals(other.m_CurrentValue);
70 }
71
72 bool DataSeriesIterator::operator!=(const DataSeriesIterator &other) const
73 {
74 return !(*this == other);
75 }
@@ -77,6 +77,13 public:
77 }
77 }
78 }
78 }
79
79
80 void prev()
81 {
82 for (auto &it : m_Its) {
83 --it;
84 }
85 }
86
80 bool operator==(const IteratorValue &other) const { return m_Its == other.m_Its; }
87 bool operator==(const IteratorValue &other) const { return m_Its == other.m_Its; }
81
88
82 private:
89 private:
@@ -105,6 +112,12 public:
105 return *this;
112 return *this;
106 }
113 }
107
114
115 Iterator &operator--()
116 {
117 m_CurrentValue.prev();
118 return *this;
119 }
120
108 pointer operator->() const { return &m_CurrentValue; }
121 pointer operator->() const { return &m_CurrentValue; }
109 reference operator*() const { return m_CurrentValue; }
122 reference operator*() const { return m_CurrentValue; }
110
123
@@ -21,6 +21,57 inline const QLoggingCategory &LOG_DataSeries()
21 return category;
21 return category;
22 }
22 }
23
23
24 template <int Dim>
25 class DataSeries;
26
27 namespace dataseries_detail {
28
29 template <int Dim>
30 class IteratorValue : public DataSeriesIteratorValue::Impl {
31 public:
32 explicit IteratorValue(const DataSeries<Dim> &dataSeries, bool begin)
33 : m_XIt(begin ? dataSeries.xAxisData()->cbegin() : dataSeries.xAxisData()->cend()),
34 m_ValuesIt(begin ? dataSeries.valuesData()->cbegin()
35 : dataSeries.valuesData()->cend())
36 {
37 }
38 IteratorValue(const IteratorValue &other) = default;
39
40 std::unique_ptr<DataSeriesIteratorValue::Impl> clone() const override
41 {
42 return std::make_unique<IteratorValue<Dim> >(*this);
43 }
44
45 bool equals(const DataSeriesIteratorValue::Impl &other) const override try {
46 const auto &otherImpl = dynamic_cast<const IteratorValue &>(other);
47 return std::tie(m_XIt, m_ValuesIt) == std::tie(otherImpl.m_XIt, otherImpl.m_ValuesIt);
48 }
49 catch (const std::bad_cast &) {
50 return false;
51 }
52
53 void next() override
54 {
55 ++m_XIt;
56 ++m_ValuesIt;
57 }
58
59 void prev() override
60 {
61 --m_XIt;
62 --m_ValuesIt;
63 }
64
65 double x() const override { return m_XIt->at(0); }
66 double value() const override { return m_ValuesIt->at(0); }
67 double value(int componentIndex) const override { return m_ValuesIt->at(componentIndex); }
68
69 private:
70 ArrayData<1>::Iterator m_XIt;
71 typename ArrayData<Dim>::Iterator m_ValuesIt;
72 };
73 } // namespace dataseries_detail
74
24 /**
75 /**
25 * @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
76 * @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
26 *
77 *
@@ -34,71 +85,6 inline const QLoggingCategory &LOG_DataSeries()
34 template <int Dim>
85 template <int Dim>
35 class SCIQLOP_CORE_EXPORT DataSeries : public IDataSeries {
86 class SCIQLOP_CORE_EXPORT DataSeries : public IDataSeries {
36 public:
87 public:
37 class IteratorValue {
38 public:
39 explicit IteratorValue(const DataSeries &dataSeries, bool begin)
40 : m_XIt(begin ? dataSeries.xAxisData()->cbegin() : dataSeries.xAxisData()->cend()),
41 m_ValuesIt(begin ? dataSeries.valuesData()->cbegin()
42 : dataSeries.valuesData()->cend())
43 {
44 }
45
46 double x() const { return m_XIt->at(0); }
47 double value() const { return m_ValuesIt->at(0); }
48 double value(int componentIndex) const { return m_ValuesIt->at(componentIndex); }
49
50 void next()
51 {
52 ++m_XIt;
53 ++m_ValuesIt;
54 }
55
56 bool operator==(const IteratorValue &other) const
57 {
58 return std::tie(m_XIt, m_ValuesIt) == std::tie(other.m_XIt, other.m_ValuesIt);
59 }
60
61 private:
62 ArrayData<1>::Iterator m_XIt;
63 typename ArrayData<Dim>::Iterator m_ValuesIt;
64 };
65
66 class Iterator {
67 public:
68 using iterator_category = std::forward_iterator_tag;
69 using value_type = const IteratorValue;
70 using difference_type = std::ptrdiff_t;
71 using pointer = value_type *;
72 using reference = value_type &;
73
74 Iterator(const DataSeries &dataSeries, bool begin) : m_CurrentValue{dataSeries, begin} {}
75 virtual ~Iterator() noexcept = default;
76 Iterator(const Iterator &) = default;
77 Iterator(Iterator &&) = default;
78 Iterator &operator=(const Iterator &) = default;
79 Iterator &operator=(Iterator &&) = default;
80
81 Iterator &operator++()
82 {
83 m_CurrentValue.next();
84 return *this;
85 }
86
87 pointer operator->() const { return &m_CurrentValue; }
88
89 reference operator*() const { return m_CurrentValue; }
90
91 bool operator==(const Iterator &other) const
92 {
93 return m_CurrentValue == other.m_CurrentValue;
94 }
95
96 bool operator!=(const Iterator &other) const { return !(*this == other); }
97
98 private:
99 IteratorValue m_CurrentValue;
100 };
101
102 /// @sa IDataSeries::xAxisData()
88 /// @sa IDataSeries::xAxisData()
103 std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; }
89 std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; }
104 const std::shared_ptr<ArrayData<1> > xAxisData() const { return m_XAxisData; }
90 const std::shared_ptr<ArrayData<1> > xAxisData() const { return m_XAxisData; }
@@ -193,11 +179,38 public:
193 // Iterators //
179 // Iterators //
194 // ///////// //
180 // ///////// //
195
181
196 Iterator cbegin() const { return Iterator{*this, true}; }
182 DataSeriesIterator cbegin() const override
183 {
184 return DataSeriesIterator{DataSeriesIteratorValue{
185 std::make_unique<dataseries_detail::IteratorValue<Dim> >(*this, true)}};
186 }
187
188 DataSeriesIterator cend() const override
189 {
190 return DataSeriesIterator{DataSeriesIteratorValue{
191 std::make_unique<dataseries_detail::IteratorValue<Dim> >(*this, false)}};
192 }
193
194 /// @sa IDataSeries::minData()
195 DataSeriesIterator minData(double minXAxisData) const override
196 {
197 return std::lower_bound(
198 cbegin(), cend(), minXAxisData,
199 [](const auto &itValue, const auto &value) { return itValue.x() < value; });
200 }
201
202 /// @sa IDataSeries::maxData()
203 DataSeriesIterator maxData(double maxXAxisData) const override
204 {
205 // Gets the first element that greater than max value
206 auto it = std::upper_bound(
207 cbegin(), cend(), maxXAxisData,
208 [](const auto &value, const auto &itValue) { return value < itValue.x(); });
197
209
198 Iterator cend() const { return Iterator{*this, false}; }
210 return it == cbegin() ? cend() : --it;
211 }
199
212
200 std::pair<Iterator, Iterator> subData(double min, double max) const
213 std::pair<DataSeriesIterator, DataSeriesIterator> subData(double min, double max) const override
201 {
214 {
202 if (min > max) {
215 if (min > max) {
203 std::swap(min, max);
216 std::swap(min, max);
@@ -2,6 +2,7
2 #define SCIQLOP_IDATASERIES_H
2 #define SCIQLOP_IDATASERIES_H
3
3
4 #include <Common/MetaTypes.h>
4 #include <Common/MetaTypes.h>
5 #include <Data/DataSeriesIterator.h>
5 #include <Data/SqpRange.h>
6 #include <Data/SqpRange.h>
6
7
7 #include <memory>
8 #include <memory>
@@ -62,6 +63,28 public:
62 virtual std::unique_ptr<IDataSeries> clone() const = 0;
63 virtual std::unique_ptr<IDataSeries> clone() const = 0;
63 virtual SqpRange range() const = 0;
64 virtual SqpRange range() const = 0;
64
65
66 // ///////// //
67 // Iterators //
68 // ///////// //
69
70 virtual DataSeriesIterator cbegin() const = 0;
71 virtual DataSeriesIterator cend() const = 0;
72
73 /// @return the iterator to the first entry of the data series whose x-axis data is greater than
74 /// or equal to the value passed in parameter, or the end iterator if there is no matching value
75 virtual DataSeriesIterator minData(double minXAxisData) const = 0;
76
77 /// @return the iterator to the last entry of the data series whose x-axis data is less than or
78 /// equal to the value passed in parameter, or the end iterator if there is no matching value
79 virtual DataSeriesIterator maxData(double maxXAxisData) const = 0;
80
81 virtual std::pair<DataSeriesIterator, DataSeriesIterator> subData(double min,
82 double max) const = 0;
83
84 // /////// //
85 // Mutexes //
86 // /////// //
87
65 virtual void lockRead() = 0;
88 virtual void lockRead() = 0;
66 virtual void lockWrite() = 0;
89 virtual void lockWrite() = 0;
67 virtual void unlock() = 0;
90 virtual void unlock() = 0;
@@ -154,18 +154,31 QVariant VariableModel::data(const QModelIndex &index, int role) const
154 if (role == Qt::DisplayRole) {
154 if (role == Qt::DisplayRole) {
155 if (auto variable = impl->m_Variables.at(index.row()).get()) {
155 if (auto variable = impl->m_Variables.at(index.row()).get()) {
156 /// Lambda function that builds the variant to return for a time value
156 /// Lambda function that builds the variant to return for a time value
157 auto dateTimeVariant = [](double secs) {
157 /// @param getValueFun function used to get for a data series the iterator on the entry
158 auto dateTime = DateUtils::dateTime(secs);
158 /// that contains the time value to display
159 return dateTime.toString(DATETIME_FORMAT);
159 auto dateTimeVariant = [variable](const auto &getValueFun) {
160 if (auto dataSeries = variable->dataSeries()) {
161 auto it = getValueFun(*dataSeries);
162 return (it != dataSeries->cend())
163 ? DateUtils::dateTime(it->x()).toString(DATETIME_FORMAT)
164 : QVariant{};
165 }
166 else {
167 return QVariant{};
168 }
160 };
169 };
161
170
162 switch (index.column()) {
171 switch (index.column()) {
163 case NAME_COLUMN:
172 case NAME_COLUMN:
164 return variable->name();
173 return variable->name();
165 case TSTART_COLUMN:
174 case TSTART_COLUMN:
166 return dateTimeVariant(variable->range().m_TStart);
175 // Shows the min value of the data series above the range tstart
176 return dateTimeVariant([min = variable->range().m_TStart](
177 const auto &dataSeries) { return dataSeries.minData(min); });
167 case TEND_COLUMN:
178 case TEND_COLUMN:
168 return dateTimeVariant(variable->range().m_TEnd);
179 // Shows the max value of the data series under the range tend
180 return dateTimeVariant([max = variable->range().m_TEnd](
181 const auto &dataSeries) { return dataSeries.maxData(max); });
169 case UNIT_COLUMN:
182 case UNIT_COLUMN:
170 return variable->metadata().value(QStringLiteral("units"));
183 return variable->metadata().value(QStringLiteral("units"));
171 case MISSION_COLUMN:
184 case MISSION_COLUMN:
@@ -24,6 +24,20 private slots:
24 void testMerge();
24 void testMerge();
25
25
26 /// Input test data
26 /// Input test data
27 /// @sa testMinData()
28 void testMinData_data();
29
30 /// Tests get min data of a data series
31 void testMinData();
32
33 /// Input test data
34 /// @sa testMaxData()
35 void testMaxData_data();
36
37 /// Tests get max data of a data series
38 void testMaxData();
39
40 /// Input test data
27 /// @sa testSubdata()
41 /// @sa testSubdata()
28 void testSubdata_data();
42 void testSubdata_data();
29
43
@@ -167,6 +181,114 void TestDataSeries::testMerge()
167 seriesValuesData.cbegin()));
181 seriesValuesData.cbegin()));
168 }
182 }
169
183
184 void TestDataSeries::testMinData_data()
185 {
186 // ////////////// //
187 // Test structure //
188 // ////////////// //
189
190 // Data series to get min data
191 QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries");
192
193 // Min data
194 QTest::addColumn<double>("min");
195
196 // Expected results
197 QTest::addColumn<bool>(
198 "expectedOK"); // if true, expects to have a result (i.e. the iterator != end iterator)
199 QTest::addColumn<double>(
200 "expectedMin"); // Expected value when method doesn't return end iterator
201
202 // ////////// //
203 // Test cases //
204 // ////////// //
205
206 QTest::newRow("minData1") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
207 << 0. << true << 1.;
208 QTest::newRow("minData2") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
209 << 1. << true << 1.;
210 QTest::newRow("minData3") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
211 << 1.1 << true << 2.;
212 QTest::newRow("minData4") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
213 << 5. << true << 5.;
214 QTest::newRow("minData5") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
215 << 5.1 << false << std::numeric_limits<double>::quiet_NaN();
216 QTest::newRow("minData6") << createSeries({}, {}) << 1.1 << false
217 << std::numeric_limits<double>::quiet_NaN();
218 }
219
220 void TestDataSeries::testMinData()
221 {
222 QFETCH(std::shared_ptr<ScalarSeries>, dataSeries);
223 QFETCH(double, min);
224
225 QFETCH(bool, expectedOK);
226 QFETCH(double, expectedMin);
227
228 auto it = dataSeries->minData(min);
229
230 QCOMPARE(expectedOK, it != dataSeries->cend());
231
232 // If the method doesn't return a end iterator, checks with expected value
233 if (expectedOK) {
234 QCOMPARE(expectedMin, it->x());
235 }
236 }
237
238 void TestDataSeries::testMaxData_data()
239 {
240 // ////////////// //
241 // Test structure //
242 // ////////////// //
243
244 // Data series to get max data
245 QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries");
246
247 // Max data
248 QTest::addColumn<double>("max");
249
250 // Expected results
251 QTest::addColumn<bool>(
252 "expectedOK"); // if true, expects to have a result (i.e. the iterator != end iterator)
253 QTest::addColumn<double>(
254 "expectedMax"); // Expected value when method doesn't return end iterator
255
256 // ////////// //
257 // Test cases //
258 // ////////// //
259
260 QTest::newRow("maxData1") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
261 << 6. << true << 5.;
262 QTest::newRow("maxData2") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
263 << 5. << true << 5.;
264 QTest::newRow("maxData3") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
265 << 4.9 << true << 4.;
266 QTest::newRow("maxData4") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
267 << 1.1 << true << 1.;
268 QTest::newRow("maxData5") << createSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
269 << 1. << true << 1.;
270 QTest::newRow("maxData6") << createSeries({}, {}) << 1.1 << false
271 << std::numeric_limits<double>::quiet_NaN();
272 }
273
274 void TestDataSeries::testMaxData()
275 {
276 QFETCH(std::shared_ptr<ScalarSeries>, dataSeries);
277 QFETCH(double, max);
278
279 QFETCH(bool, expectedOK);
280 QFETCH(double, expectedMax);
281
282 auto it = dataSeries->maxData(max);
283
284 QCOMPARE(expectedOK, it != dataSeries->cend());
285
286 // If the method doesn't return a end iterator, checks with expected value
287 if (expectedOK) {
288 QCOMPARE(expectedMax, it->x());
289 }
290 }
291
170 void TestDataSeries::testSubdata_data()
292 void TestDataSeries::testSubdata_data()
171 {
293 {
172 // ////////////// //
294 // ////////////// //
@@ -20,13 +20,12 void TestVariable::testNotInCacheRangeList()
20 auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
20 auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
21 auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}};
21 auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}};
22
22
23 auto sqpR = SqpRange{static_cast<double>(varRS.toMSecsSinceEpoch()),
23 auto sqpR = SqpRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)};
24 static_cast<double>(varRE.toMSecsSinceEpoch())};
25
24
26 auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
25 auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
27 auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
26 auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
28 auto sqpCR = SqpRange{static_cast<double>(varCRS.toMSecsSinceEpoch()),
27 auto sqpCR
29 static_cast<double>(varCRE.toMSecsSinceEpoch())};
28 = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)};
30
29
31 Variable var{"Var test", sqpR};
30 Variable var{"Var test", sqpR};
32 var.setCacheRange(sqpCR);
31 var.setCacheRange(sqpCR);
@@ -34,8 +33,7 void TestVariable::testNotInCacheRangeList()
34 // 1: [ts,te] < varTS
33 // 1: [ts,te] < varTS
35 auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
34 auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
36 auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
35 auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
37 auto sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
36 auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
38 static_cast<double>(te.toMSecsSinceEpoch())};
39
37
40 auto notInCach = var.provideNotInCacheRangeList(sqp);
38 auto notInCach = var.provideNotInCacheRangeList(sqp);
41
39
@@ -43,25 +41,23 void TestVariable::testNotInCacheRangeList()
43
41
44 auto notInCachRange = notInCach.first();
42 auto notInCachRange = notInCach.first();
45
43
46 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
44 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
47 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
45 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
48
46
49 // 2: ts < varTS < te < varTE
47 // 2: ts < varTS < te < varTE
50 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
48 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
51 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
49 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
52 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
50 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
53 static_cast<double>(te.toMSecsSinceEpoch())};
54 notInCach = var.provideNotInCacheRangeList(sqp);
51 notInCach = var.provideNotInCacheRangeList(sqp);
55 QCOMPARE(notInCach.size(), 1);
52 QCOMPARE(notInCach.size(), 1);
56 notInCachRange = notInCach.first();
53 notInCachRange = notInCach.first();
57 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
54 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
58 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(varCRS.toMSecsSinceEpoch()));
55 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRS));
59
56
60 // 3: varTS < ts < te < varTE
57 // 3: varTS < ts < te < varTE
61 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
58 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
62 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
59 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
63 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
60 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
64 static_cast<double>(te.toMSecsSinceEpoch())};
65 notInCach = var.provideNotInCacheRangeList(sqp);
61 notInCach = var.provideNotInCacheRangeList(sqp);
66 QCOMPARE(notInCach.size(), 0);
62 QCOMPARE(notInCach.size(), 0);
67
63
@@ -69,38 +65,35 void TestVariable::testNotInCacheRangeList()
69 // 4: varTS < ts < varTE < te
65 // 4: varTS < ts < varTE < te
70 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
66 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
71 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
67 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
72 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
68 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
73 static_cast<double>(te.toMSecsSinceEpoch())};
74 notInCach = var.provideNotInCacheRangeList(sqp);
69 notInCach = var.provideNotInCacheRangeList(sqp);
75 QCOMPARE(notInCach.size(), 1);
70 QCOMPARE(notInCach.size(), 1);
76 notInCachRange = notInCach.first();
71 notInCachRange = notInCach.first();
77 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(varCRE.toMSecsSinceEpoch()));
72 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRE));
78 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
73 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
79
74
80 // 5: varTS < varTE < ts < te
75 // 5: varTS < varTE < ts < te
81 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}};
76 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}};
82 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
77 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
83 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
78 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
84 static_cast<double>(te.toMSecsSinceEpoch())};
85 notInCach = var.provideNotInCacheRangeList(sqp);
79 notInCach = var.provideNotInCacheRangeList(sqp);
86 QCOMPARE(notInCach.size(), 1);
80 QCOMPARE(notInCach.size(), 1);
87 notInCachRange = notInCach.first();
81 notInCachRange = notInCach.first();
88 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
82 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
89 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
83 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
90
84
91 // 6: ts <varTS < varTE < te
85 // 6: ts <varTS < varTE < te
92 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
86 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
93 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
87 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
94 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
88 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
95 static_cast<double>(te.toMSecsSinceEpoch())};
96 notInCach = var.provideNotInCacheRangeList(sqp);
89 notInCach = var.provideNotInCacheRangeList(sqp);
97 QCOMPARE(notInCach.size(), 2);
90 QCOMPARE(notInCach.size(), 2);
98 notInCachRange = notInCach.first();
91 notInCachRange = notInCach.first();
99 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
92 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
100 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(varCRS.toMSecsSinceEpoch()));
93 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRS));
101 notInCachRange = notInCach[1];
94 notInCachRange = notInCach[1];
102 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(varCRE.toMSecsSinceEpoch()));
95 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRE));
103 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
96 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
104 }
97 }
105
98
106
99
@@ -109,13 +102,12 void TestVariable::testInCacheRangeList()
109 auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
102 auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
110 auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}};
103 auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}};
111
104
112 auto sqpR = SqpRange{static_cast<double>(varRS.toMSecsSinceEpoch()),
105 auto sqpR = SqpRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)};
113 static_cast<double>(varRE.toMSecsSinceEpoch())};
114
106
115 auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
107 auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
116 auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
108 auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
117 auto sqpCR = SqpRange{static_cast<double>(varCRS.toMSecsSinceEpoch()),
109 auto sqpCR
118 static_cast<double>(varCRE.toMSecsSinceEpoch())};
110 = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)};
119
111
120 Variable var{"Var test", sqpR};
112 Variable var{"Var test", sqpR};
121 var.setCacheRange(sqpCR);
113 var.setCacheRange(sqpCR);
@@ -123,8 +115,7 void TestVariable::testInCacheRangeList()
123 // 1: [ts,te] < varTS
115 // 1: [ts,te] < varTS
124 auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
116 auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
125 auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
117 auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
126 auto sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
118 auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
127 static_cast<double>(te.toMSecsSinceEpoch())};
128
119
129 auto notInCach = var.provideInCacheRangeList(sqp);
120 auto notInCach = var.provideInCacheRangeList(sqp);
130
121
@@ -133,54 +124,49 void TestVariable::testInCacheRangeList()
133 // 2: ts < varTS < te < varTE
124 // 2: ts < varTS < te < varTE
134 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
125 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
135 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
126 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
136 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
127 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
137 static_cast<double>(te.toMSecsSinceEpoch())};
138 notInCach = var.provideInCacheRangeList(sqp);
128 notInCach = var.provideInCacheRangeList(sqp);
139 QCOMPARE(notInCach.size(), 1);
129 QCOMPARE(notInCach.size(), 1);
140 auto notInCachRange = notInCach.first();
130 auto notInCachRange = notInCach.first();
141 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(varCRS.toMSecsSinceEpoch()));
131 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRS));
142 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
132 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
143
133
144 // 3: varTS < ts < te < varTE
134 // 3: varTS < ts < te < varTE
145 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
135 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
146 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
136 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
147 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
137 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
148 static_cast<double>(te.toMSecsSinceEpoch())};
149 notInCach = var.provideInCacheRangeList(sqp);
138 notInCach = var.provideInCacheRangeList(sqp);
150 QCOMPARE(notInCach.size(), 1);
139 QCOMPARE(notInCach.size(), 1);
151 notInCachRange = notInCach.first();
140 notInCachRange = notInCach.first();
152 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
141 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
153 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
142 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te));
154
143
155 // 4: varTS < ts < varTE < te
144 // 4: varTS < ts < varTE < te
156 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
145 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}};
157 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
146 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
158 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
147 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
159 static_cast<double>(te.toMSecsSinceEpoch())};
160 notInCach = var.provideInCacheRangeList(sqp);
148 notInCach = var.provideInCacheRangeList(sqp);
161 QCOMPARE(notInCach.size(), 1);
149 QCOMPARE(notInCach.size(), 1);
162 notInCachRange = notInCach.first();
150 notInCachRange = notInCach.first();
163 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
151 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts));
164 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(varCRE.toMSecsSinceEpoch()));
152 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRE));
165
153
166 // 5: varTS < varTE < ts < te
154 // 5: varTS < varTE < ts < te
167 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}};
155 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}};
168 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
156 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
169 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
157 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
170 static_cast<double>(te.toMSecsSinceEpoch())};
171 notInCach = var.provideInCacheRangeList(sqp);
158 notInCach = var.provideInCacheRangeList(sqp);
172 QCOMPARE(notInCach.size(), 0);
159 QCOMPARE(notInCach.size(), 0);
173
160
174 // 6: ts <varTS < varTE < te
161 // 6: ts <varTS < varTE < te
175 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
162 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
176 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
163 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
177 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
164 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
178 static_cast<double>(te.toMSecsSinceEpoch())};
179 notInCach = var.provideInCacheRangeList(sqp);
165 notInCach = var.provideInCacheRangeList(sqp);
180 QCOMPARE(notInCach.size(), 1);
166 QCOMPARE(notInCach.size(), 1);
181 notInCachRange = notInCach.first();
167 notInCachRange = notInCach.first();
182 QCOMPARE(notInCachRange.m_TStart, static_cast<double>(varCRS.toMSecsSinceEpoch()));
168 QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRS));
183 QCOMPARE(notInCachRange.m_TEnd, static_cast<double>(varCRE.toMSecsSinceEpoch()));
169 QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRE));
184 }
170 }
185
171
186
172
@@ -22,18 +22,15 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
22
22
23 auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
23 auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
24 auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
24 auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
25 auto sqp0 = SqpRange{static_cast<double>(ts0.toMSecsSinceEpoch()),
25 auto sqp0 = SqpRange{DateUtils::secondsSinceEpoch(ts0), DateUtils::secondsSinceEpoch(te0)};
26 static_cast<double>(te0.toMSecsSinceEpoch())};
27
26
28 auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}};
27 auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}};
29 auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}};
28 auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}};
30 auto sqp1 = SqpRange{static_cast<double>(ts1.toMSecsSinceEpoch()),
29 auto sqp1 = SqpRange{DateUtils::secondsSinceEpoch(ts1), DateUtils::secondsSinceEpoch(te1)};
31 static_cast<double>(te1.toMSecsSinceEpoch())};
32
30
33 auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}};
31 auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}};
34 auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}};
32 auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}};
35 auto sqp2 = SqpRange{static_cast<double>(ts2.toMSecsSinceEpoch()),
33 auto sqp2 = SqpRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)};
36 static_cast<double>(te2.toMSecsSinceEpoch())};
37
34
38 auto var0 = std::make_shared<Variable>("", sqp0);
35 auto var0 = std::make_shared<Variable>("", sqp0);
39
36
@@ -44,210 +41,197 void TestVariableCacheController::testProvideNotInCacheDateTimeList()
44 // first case [ts,te] < ts0
41 // first case [ts,te] < ts0
45 auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
42 auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
46 auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
43 auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}};
47 auto sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
44 auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
48 static_cast<double>(te.toMSecsSinceEpoch())};
49
45
50
46
51 auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
47 auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
52
48
53 QCOMPARE(notInCach.size(), 1);
49 QCOMPARE(notInCach.size(), 1);
54 auto notInCacheSqp = notInCach.first();
50 auto notInCacheSqp = notInCach.first();
55 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
51 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts));
56 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
52 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te));
57
53
58
54
59 // second case ts < ts0 && ts0 < te <= te0
55 // second case ts < ts0 && ts0 < te <= te0
60 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
56 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
61 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
57 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
62 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
58 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
63 static_cast<double>(te.toMSecsSinceEpoch())};
64
59
65
60
66 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
61 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
67
62
68 QCOMPARE(notInCach.size(), 1);
63 QCOMPARE(notInCach.size(), 1);
69 notInCacheSqp = notInCach.first();
64 notInCacheSqp = notInCach.first();
70 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
65 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts));
71 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
66 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0));
72
67
73 // 3th case ts < ts0 && te0 < te <= ts1
68 // 3th case ts < ts0 && te0 < te <= ts1
74 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
69 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
75 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
70 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
76 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
71 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
77 static_cast<double>(te.toMSecsSinceEpoch())};
78
72
79
73
80 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
74 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
81
75
82 QCOMPARE(notInCach.size(), 2);
76 QCOMPARE(notInCach.size(), 2);
83 notInCacheSqp = notInCach.first();
77 notInCacheSqp = notInCach.first();
84 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
78 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts));
85 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
79 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0));
86
80
87 notInCacheSqp = notInCach.at(1);
81 notInCacheSqp = notInCach.at(1);
88 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
82 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0));
89 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
83 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te));
90
84
91 // 4th case ts < ts0 && ts1 < te <= te1
85 // 4th case ts < ts0 && ts1 < te <= te1
92 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
86 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
93 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}};
87 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}};
94 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
88 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
95 static_cast<double>(te.toMSecsSinceEpoch())};
96
89
97
90
98 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
91 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
99
92
100 QCOMPARE(notInCach.size(), 2);
93 QCOMPARE(notInCach.size(), 2);
101 notInCacheSqp = notInCach.first();
94 notInCacheSqp = notInCach.first();
102 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
95 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts));
103 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
96 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0));
104
97
105 notInCacheSqp = notInCach.at(1);
98 notInCacheSqp = notInCach.at(1);
106 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
99 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0));
107 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
100 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1));
108
101
109 // 5th case ts < ts0 && te3 < te
102 // 5th case ts < ts0 && te3 < te
110 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
103 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}};
111 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}};
104 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}};
112 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
105 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
113 static_cast<double>(te.toMSecsSinceEpoch())};
114
106
115
107
116 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
108 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
117
109
118 QCOMPARE(notInCach.size(), 4);
110 QCOMPARE(notInCach.size(), 4);
119 notInCacheSqp = notInCach.first();
111 notInCacheSqp = notInCach.first();
120 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
112 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts));
121 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts0.toMSecsSinceEpoch()));
113 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0));
122
114
123 notInCacheSqp = notInCach.at(1);
115 notInCacheSqp = notInCach.at(1);
124 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
116 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0));
125 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
117 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1));
126
118
127 notInCacheSqp = notInCach.at(2);
119 notInCacheSqp = notInCach.at(2);
128 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
120 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te1));
129 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
121 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts2));
130
122
131 notInCacheSqp = notInCach.at(3);
123 notInCacheSqp = notInCach.at(3);
132 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
124 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te2));
133 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
125 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te));
134
126
135
127
136 // 6th case ts2 < ts
128 // 6th case ts2 < ts
137 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 45, 0, 0}};
129 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 45, 0, 0}};
138 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}};
130 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}};
139 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
131 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
140 static_cast<double>(te.toMSecsSinceEpoch())};
141
132
142
133
143 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
134 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
144
135
145 QCOMPARE(notInCach.size(), 1);
136 QCOMPARE(notInCach.size(), 1);
146 notInCacheSqp = notInCach.first();
137 notInCacheSqp = notInCach.first();
147 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
138 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts));
148 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
139 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te));
149
140
150 // 7th case ts = te0 && te < ts1
141 // 7th case ts = te0 && te < ts1
151 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
142 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
152 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
143 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
153 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
144 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
154 static_cast<double>(te.toMSecsSinceEpoch())};
155
145
156
146
157 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
147 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
158
148
159 QCOMPARE(notInCach.size(), 1);
149 QCOMPARE(notInCach.size(), 1);
160 notInCacheSqp = notInCach.first();
150 notInCacheSqp = notInCach.first();
161 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
151 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0));
162 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
152 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te));
163
153
164 // 8th case ts0 < ts < te0 && te < ts1
154 // 8th case ts0 < ts < te0 && te < ts1
165 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
155 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
166 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
156 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
167 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
157 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
168 static_cast<double>(te.toMSecsSinceEpoch())};
169
158
170
159
171 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
160 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
172
161
173 QCOMPARE(notInCach.size(), 1);
162 QCOMPARE(notInCach.size(), 1);
174 notInCacheSqp = notInCach.first();
163 notInCacheSqp = notInCach.first();
175 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
164 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0));
176 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
165 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te));
177
166
178 // 9th case ts0 < ts < te0 && ts1 < te < te1
167 // 9th case ts0 < ts < te0 && ts1 < te < te1
179 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
168 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}};
180 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}};
169 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}};
181 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
170 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
182 static_cast<double>(te.toMSecsSinceEpoch())};
183
171
184
172
185 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
173 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
186
174
187 QCOMPARE(notInCach.size(), 1);
175 QCOMPARE(notInCach.size(), 1);
188 notInCacheSqp = notInCach.first();
176 notInCacheSqp = notInCach.first();
189 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te0.toMSecsSinceEpoch()));
177 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0));
190 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
178 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1));
191
179
192 // 10th case te1 < ts < te < ts2
180 // 10th case te1 < ts < te < ts2
193 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}};
181 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}};
194 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}};
182 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}};
195 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
183 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
196 static_cast<double>(te.toMSecsSinceEpoch())};
197
184
198
185
199 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
186 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
200
187
201 QCOMPARE(notInCach.size(), 1);
188 QCOMPARE(notInCach.size(), 1);
202 notInCacheSqp = notInCach.first();
189 notInCacheSqp = notInCach.first();
203 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
190 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts));
204 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
191 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te));
205
192
206 // 11th case te0 < ts < ts1 && te3 < te
193 // 11th case te0 < ts < ts1 && te3 < te
207 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
194 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
208 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}};
195 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}};
209 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
196 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
210 static_cast<double>(te.toMSecsSinceEpoch())};
211
197
212
198
213 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
199 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
214
200
215 QCOMPARE(notInCach.size(), 3);
201 QCOMPARE(notInCach.size(), 3);
216 notInCacheSqp = notInCach.first();
202 notInCacheSqp = notInCach.first();
217 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
203 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts));
218 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
204 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1));
219
205
220 notInCacheSqp = notInCach.at(1);
206 notInCacheSqp = notInCach.at(1);
221 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
207 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te1));
222 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts2.toMSecsSinceEpoch()));
208 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts2));
223
209
224 notInCacheSqp = notInCach.at(2);
210 notInCacheSqp = notInCach.at(2);
225 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te2.toMSecsSinceEpoch()));
211 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te2));
226 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
212 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te));
227
213
228 // 12th case te0 < ts < ts1 && te3 < te
214 // 12th case te0 < ts < ts1 && te3 < te
229 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
215 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}};
230 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}};
216 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}};
231 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
217 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
232 static_cast<double>(te.toMSecsSinceEpoch())};
233
218
234 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
219 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
235
220
236 QCOMPARE(notInCach.size(), 2);
221 QCOMPARE(notInCach.size(), 2);
237 notInCacheSqp = notInCach.first();
222 notInCacheSqp = notInCach.first();
238 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(ts.toMSecsSinceEpoch()));
223 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts));
239 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(ts1.toMSecsSinceEpoch()));
224 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1));
240
225
241 notInCacheSqp = notInCach.at(1);
226 notInCacheSqp = notInCach.at(1);
242 QCOMPARE(notInCacheSqp.m_TStart, static_cast<double>(te1.toMSecsSinceEpoch()));
227 QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te1));
243 QCOMPARE(notInCacheSqp.m_TEnd, static_cast<double>(te.toMSecsSinceEpoch()));
228 QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te));
244
229
245
230
246 // 12th case ts0 < ts < te0
231 // 12th case ts0 < ts < te0
247 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 10, 0}};
232 ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 10, 0}};
248 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 50, 0}};
233 te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 50, 0}};
249 sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()),
234 sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)};
250 static_cast<double>(te.toMSecsSinceEpoch())};
251
235
252 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
236 notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp);
253 QCOMPARE(notInCach.size(), 0);
237 QCOMPARE(notInCach.size(), 0);
@@ -260,33 +244,27 void TestVariableCacheController::testAddDateTime()
260
244
261 auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
245 auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}};
262 auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
246 auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
263 auto sqp0 = SqpRange{static_cast<double>(ts0.toMSecsSinceEpoch()),
247 auto sqp0 = SqpRange{DateUtils::secondsSinceEpoch(ts0), DateUtils::secondsSinceEpoch(te0)};
264 static_cast<double>(te0.toMSecsSinceEpoch())};
265
248
266 auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}};
249 auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}};
267 auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}};
250 auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}};
268 auto sqp1 = SqpRange{static_cast<double>(ts1.toMSecsSinceEpoch()),
251 auto sqp1 = SqpRange{DateUtils::secondsSinceEpoch(ts1), DateUtils::secondsSinceEpoch(te1)};
269 static_cast<double>(te1.toMSecsSinceEpoch())};
270
252
271 auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}};
253 auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}};
272 auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}};
254 auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}};
273 auto sqp2 = SqpRange{static_cast<double>(ts2.toMSecsSinceEpoch()),
255 auto sqp2 = SqpRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)};
274 static_cast<double>(te2.toMSecsSinceEpoch())};
275
256
276 auto ts01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
257 auto ts01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
277 auto te01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}};
258 auto te01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}};
278 auto sqp01 = SqpRange{static_cast<double>(ts01.toMSecsSinceEpoch()),
259 auto sqp01 = SqpRange{DateUtils::secondsSinceEpoch(ts01), DateUtils::secondsSinceEpoch(te01)};
279 static_cast<double>(te01.toMSecsSinceEpoch())};
280
260
281 auto ts3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 14, 0, 0}};
261 auto ts3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 14, 0, 0}};
282 auto te3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 16, 0, 0}};
262 auto te3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 16, 0, 0}};
283 auto sqp3 = SqpRange{static_cast<double>(ts3.toMSecsSinceEpoch()),
263 auto sqp3 = SqpRange{DateUtils::secondsSinceEpoch(ts3), DateUtils::secondsSinceEpoch(te3)};
284 static_cast<double>(te3.toMSecsSinceEpoch())};
285
264
286 auto ts03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
265 auto ts03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}};
287 auto te03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}};
266 auto te03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}};
288 auto sqp03 = SqpRange{static_cast<double>(ts03.toMSecsSinceEpoch()),
267 auto sqp03 = SqpRange{DateUtils::secondsSinceEpoch(ts03), DateUtils::secondsSinceEpoch(te03)};
289 static_cast<double>(te03.toMSecsSinceEpoch())};
290
268
291
269
292 auto var0 = std::make_shared<Variable>("", sqp0);
270 auto var0 = std::make_shared<Variable>("", sqp0);
@@ -297,28 +275,28 void TestVariableCacheController::testAddDateTime()
297 auto dateCacheList = variableCacheController.dateCacheList(var0);
275 auto dateCacheList = variableCacheController.dateCacheList(var0);
298 QCOMPARE(dateCacheList.count(), 1);
276 QCOMPARE(dateCacheList.count(), 1);
299 auto dateCache = dateCacheList.at(0);
277 auto dateCache = dateCacheList.at(0);
300 QCOMPARE(dateCache.m_TStart, static_cast<double>(ts0.toMSecsSinceEpoch()));
278 QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0));
301 QCOMPARE(dateCache.m_TEnd, static_cast<double>(te0.toMSecsSinceEpoch()));
279 QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te0));
302
280
303 // 2nd case: add a second interval : sqp1 > sqp0
281 // 2nd case: add a second interval : sqp1 > sqp0
304 variableCacheController.addDateTime(var0, sqp1);
282 variableCacheController.addDateTime(var0, sqp1);
305 dateCacheList = variableCacheController.dateCacheList(var0);
283 dateCacheList = variableCacheController.dateCacheList(var0);
306 QCOMPARE(dateCacheList.count(), 2);
284 QCOMPARE(dateCacheList.count(), 2);
307 dateCache = dateCacheList.at(0);
285 dateCache = dateCacheList.at(0);
308 QCOMPARE(dateCache.m_TStart, static_cast<double>(ts0.toMSecsSinceEpoch()));
286 QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0));
309 QCOMPARE(dateCache.m_TEnd, static_cast<double>(te0.toMSecsSinceEpoch()));
287 QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te0));
310
288
311 dateCache = dateCacheList.at(1);
289 dateCache = dateCacheList.at(1);
312 QCOMPARE(dateCache.m_TStart, static_cast<double>(ts1.toMSecsSinceEpoch()));
290 QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts1));
313 QCOMPARE(dateCache.m_TEnd, static_cast<double>(te1.toMSecsSinceEpoch()));
291 QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te1));
314
292
315 // 3th case: merge sqp0 & sqp1 with sqp01
293 // 3th case: merge sqp0 & sqp1 with sqp01
316 variableCacheController.addDateTime(var0, sqp01);
294 variableCacheController.addDateTime(var0, sqp01);
317 dateCacheList = variableCacheController.dateCacheList(var0);
295 dateCacheList = variableCacheController.dateCacheList(var0);
318 QCOMPARE(dateCacheList.count(), 1);
296 QCOMPARE(dateCacheList.count(), 1);
319 dateCache = dateCacheList.at(0);
297 dateCache = dateCacheList.at(0);
320 QCOMPARE(dateCache.m_TStart, static_cast<double>(ts0.toMSecsSinceEpoch()));
298 QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0));
321 QCOMPARE(dateCache.m_TEnd, static_cast<double>(te1.toMSecsSinceEpoch()));
299 QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te1));
322
300
323
301
324 // 4th case: add a second interval : sqp1 > sqp0
302 // 4th case: add a second interval : sqp1 > sqp0
@@ -327,16 +305,16 void TestVariableCacheController::testAddDateTime()
327 dateCacheList = variableCacheController.dateCacheList(var0);
305 dateCacheList = variableCacheController.dateCacheList(var0);
328 QCOMPARE(dateCacheList.count(), 3);
306 QCOMPARE(dateCacheList.count(), 3);
329 dateCache = dateCacheList.at(0);
307 dateCache = dateCacheList.at(0);
330 QCOMPARE(dateCache.m_TStart, static_cast<double>(ts0.toMSecsSinceEpoch()));
308 QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0));
331 QCOMPARE(dateCache.m_TEnd, static_cast<double>(te1.toMSecsSinceEpoch()));
309 QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te1));
332
310
333 dateCache = dateCacheList.at(1);
311 dateCache = dateCacheList.at(1);
334 QCOMPARE(dateCache.m_TStart, static_cast<double>(ts3.toMSecsSinceEpoch()));
312 QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts3));
335 QCOMPARE(dateCache.m_TEnd, static_cast<double>(te3.toMSecsSinceEpoch()));
313 QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te3));
336
314
337 dateCache = dateCacheList.at(2);
315 dateCache = dateCacheList.at(2);
338 QCOMPARE(dateCache.m_TStart, static_cast<double>(ts2.toMSecsSinceEpoch()));
316 QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts2));
339 QCOMPARE(dateCache.m_TEnd, static_cast<double>(te2.toMSecsSinceEpoch()));
317 QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te2));
340
318
341
319
342 // 5th case: merge all interval
320 // 5th case: merge all interval
@@ -344,8 +322,8 void TestVariableCacheController::testAddDateTime()
344 dateCacheList = variableCacheController.dateCacheList(var0);
322 dateCacheList = variableCacheController.dateCacheList(var0);
345 QCOMPARE(dateCacheList.count(), 1);
323 QCOMPARE(dateCacheList.count(), 1);
346 dateCache = dateCacheList.at(0);
324 dateCache = dateCacheList.at(0);
347 QCOMPARE(dateCache.m_TStart, static_cast<double>(ts0.toMSecsSinceEpoch()));
325 QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0));
348 QCOMPARE(dateCache.m_TEnd, static_cast<double>(te03.toMSecsSinceEpoch()));
326 QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te03));
349 }
327 }
350
328
351
329
@@ -3,6 +3,8 Common/spimpl\.h:\d+:.*
3
3
4 # Ignore false positive relative to two class definitions in a same file
4 # Ignore false positive relative to two class definitions in a same file
5 DataSourceItem\.h:\d+:.*IPSIS_S01.*
5 DataSourceItem\.h:\d+:.*IPSIS_S01.*
6 DataSeries\.h:\d+:.*IPSIS_S01.*
7 DataSeriesIterator\.h:\d+:.*IPSIS_S01.*
6
8
7 # Ignore false positive relative to a template class
9 # Ignore false positive relative to a template class
8 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (D)
10 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (D)
@@ -11,6 +13,7 ArrayData\.h:\d+:.*IPSIS_S06.*found: (D)
11 ArrayData\.h:\d+:.*IPSIS_S06.*found: (Dim)
13 ArrayData\.h:\d+:.*IPSIS_S06.*found: (Dim)
12 DataSeries\.h:\d+:.*IPSIS_S04_METHOD.*found: LOG_DataSeries
14 DataSeries\.h:\d+:.*IPSIS_S04_METHOD.*found: LOG_DataSeries
13 DataSeries\.h:\d+:.*IPSIS_S04_VARIABLE.*
15 DataSeries\.h:\d+:.*IPSIS_S04_VARIABLE.*
16 DataSeries\.h:\d+:.*IPSIS_S04_NAMESPACE.*found: (dataseries_detail)
14
17
15 # Ignore false positive relative to iterators
18 # Ignore false positive relative to iterators
16 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (forward_iterator_tag)
19 ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (forward_iterator_tag)
@@ -27,16 +30,20 ArrayData\.h:\d+:.*IPSIS_S06.*found: (ptrdiff_t)
27 ArrayData\.h:\d+:.*IPSIS_S06.*found: (pointer)
30 ArrayData\.h:\d+:.*IPSIS_S06.*found: (pointer)
28 ArrayData\.h:\d+:.*IPSIS_S06.*found: (reference)
31 ArrayData\.h:\d+:.*IPSIS_S06.*found: (reference)
29 ArrayData\.h:\d+:.*IPSIS_S06.*found: (value_type)
32 ArrayData\.h:\d+:.*IPSIS_S06.*found: (value_type)
30 DataSeries\.h:\d+:.*IPSIS_S05.*
33 DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (forward_iterator_tag)
31 DataSeries\.h:\d+:.*IPSIS_S06.*found: (iterator_category)
34 DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (DataSeriesIteratorValue)
32 DataSeries\.h:\d+:.*IPSIS_S06.*found: (forward_iterator_tag)
35 DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (ptrdiff_t)
33 DataSeries\.h:\d+:.*IPSIS_S06.*found: (value_type)
36 DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (value_type)
34 DataSeries\.h:\d+:.*IPSIS_S06.*found: (IteratorValue)
37 DataSeriesIterator\.h:\d+:.*IPSIS_S05.*
35 DataSeries\.h:\d+:.*IPSIS_S06.*found: (difference_type)
38 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (iterator_category)
36 DataSeries\.h:\d+:.*IPSIS_S06.*found: (ptrdiff_t)
39 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (forward_iterator_tag)
37 DataSeries\.h:\d+:.*IPSIS_S06.*found: (pointer)
40 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (value_type)
38 DataSeries\.h:\d+:.*IPSIS_S06.*found: (reference)
41 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (DataSeriesIteratorValue)
39 DataSeries\.h:\d+:.*IPSIS_S06.*found: (value_type)
42 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (difference_type)
43 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (ptrdiff_t)
44 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (pointer)
45 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (reference)
46 DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (value_type)
40
47
41 # Ignore false positive relative to an alias
48 # Ignore false positive relative to an alias
42 DataSourceItemAction\.h:\d+:.*IPSIS_S06.*found: (ExecuteFunction)
49 DataSourceItemAction\.h:\d+:.*IPSIS_S06.*found: (ExecuteFunction)
General Comments 0
You need to be logged in to leave comments. Login now