@@ -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 | 87 | bool operator==(const IteratorValue &other) const { return m_Its == other.m_Its; } |
|
81 | 88 | |
|
82 | 89 | private: |
@@ -105,6 +112,12 public: | |||
|
105 | 112 | return *this; |
|
106 | 113 | } |
|
107 | 114 | |
|
115 | Iterator &operator--() | |
|
116 | { | |
|
117 | m_CurrentValue.prev(); | |
|
118 | return *this; | |
|
119 | } | |
|
120 | ||
|
108 | 121 | pointer operator->() const { return &m_CurrentValue; } |
|
109 | 122 | reference operator*() const { return m_CurrentValue; } |
|
110 | 123 |
@@ -21,6 +21,57 inline const QLoggingCategory &LOG_DataSeries() | |||
|
21 | 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 | 76 | * @brief The DataSeries class is the base (abstract) implementation of IDataSeries. |
|
26 | 77 | * |
@@ -34,71 +85,6 inline const QLoggingCategory &LOG_DataSeries() | |||
|
34 | 85 | template <int Dim> |
|
35 | 86 | class SCIQLOP_CORE_EXPORT DataSeries : public IDataSeries { |
|
36 | 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 | 88 | /// @sa IDataSeries::xAxisData() |
|
103 | 89 | std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; } |
|
104 | 90 | const std::shared_ptr<ArrayData<1> > xAxisData() const { return m_XAxisData; } |
@@ -193,11 +179,38 public: | |||
|
193 | 179 | // Iterators // |
|
194 | 180 | // ///////// // |
|
195 | 181 | |
|
196 |
Iterator cbegin() const |
|
|
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 | 215 | if (min > max) { |
|
203 | 216 | std::swap(min, max); |
@@ -2,6 +2,7 | |||
|
2 | 2 | #define SCIQLOP_IDATASERIES_H |
|
3 | 3 | |
|
4 | 4 | #include <Common/MetaTypes.h> |
|
5 | #include <Data/DataSeriesIterator.h> | |
|
5 | 6 | #include <Data/SqpRange.h> |
|
6 | 7 | |
|
7 | 8 | #include <memory> |
@@ -62,6 +63,28 public: | |||
|
62 | 63 | virtual std::unique_ptr<IDataSeries> clone() const = 0; |
|
63 | 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 | 88 | virtual void lockRead() = 0; |
|
66 | 89 | virtual void lockWrite() = 0; |
|
67 | 90 | virtual void unlock() = 0; |
@@ -154,18 +154,31 QVariant VariableModel::data(const QModelIndex &index, int role) const | |||
|
154 | 154 | if (role == Qt::DisplayRole) { |
|
155 | 155 | if (auto variable = impl->m_Variables.at(index.row()).get()) { |
|
156 | 156 | /// Lambda function that builds the variant to return for a time value |
|
157 | auto dateTimeVariant = [](double secs) { | |
|
158 | auto dateTime = DateUtils::dateTime(secs); | |
|
159 | return dateTime.toString(DATETIME_FORMAT); | |
|
157 | /// @param getValueFun function used to get for a data series the iterator on the entry | |
|
158 | /// that contains the time value to display | |
|
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 | 171 | switch (index.column()) { |
|
163 | 172 | case NAME_COLUMN: |
|
164 | 173 | return variable->name(); |
|
165 | 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 | 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 | 182 | case UNIT_COLUMN: |
|
170 | 183 | return variable->metadata().value(QStringLiteral("units")); |
|
171 | 184 | case MISSION_COLUMN: |
@@ -24,6 +24,20 private slots: | |||
|
24 | 24 | void testMerge(); |
|
25 | 25 | |
|
26 | 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 | 41 | /// @sa testSubdata() |
|
28 | 42 | void testSubdata_data(); |
|
29 | 43 | |
@@ -167,6 +181,114 void TestDataSeries::testMerge() | |||
|
167 | 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 | 292 | void TestDataSeries::testSubdata_data() |
|
171 | 293 | { |
|
172 | 294 | // ////////////// // |
@@ -20,13 +20,12 void TestVariable::testNotInCacheRangeList() | |||
|
20 | 20 | auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
21 | 21 | auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}}; |
|
22 | 22 | |
|
23 | auto sqpR = SqpRange{static_cast<double>(varRS.toMSecsSinceEpoch()), | |
|
24 | static_cast<double>(varRE.toMSecsSinceEpoch())}; | |
|
23 | auto sqpR = SqpRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)}; | |
|
25 | 24 | |
|
26 | 25 | auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
27 | 26 | auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
28 | auto sqpCR = SqpRange{static_cast<double>(varCRS.toMSecsSinceEpoch()), | |
|
29 | static_cast<double>(varCRE.toMSecsSinceEpoch())}; | |
|
27 | auto sqpCR | |
|
28 | = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; | |
|
30 | 29 | |
|
31 | 30 | Variable var{"Var test", sqpR}; |
|
32 | 31 | var.setCacheRange(sqpCR); |
@@ -34,8 +33,7 void TestVariable::testNotInCacheRangeList() | |||
|
34 | 33 | // 1: [ts,te] < varTS |
|
35 | 34 | auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
36 | 35 | auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
37 | auto sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
38 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
36 | auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
39 | 37 | |
|
40 | 38 | auto notInCach = var.provideNotInCacheRangeList(sqp); |
|
41 | 39 | |
@@ -43,25 +41,23 void TestVariable::testNotInCacheRangeList() | |||
|
43 | 41 | |
|
44 | 42 | auto notInCachRange = notInCach.first(); |
|
45 | 43 | |
|
46 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
47 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
44 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
45 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
48 | 46 | |
|
49 | 47 | // 2: ts < varTS < te < varTE |
|
50 | 48 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
51 | 49 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
52 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
53 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
50 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
54 | 51 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
55 | 52 | QCOMPARE(notInCach.size(), 1); |
|
56 | 53 | notInCachRange = notInCach.first(); |
|
57 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
58 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
54 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
55 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRS)); | |
|
59 | 56 | |
|
60 | 57 | // 3: varTS < ts < te < varTE |
|
61 | 58 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
62 | 59 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
63 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
64 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
60 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
65 | 61 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
66 | 62 | QCOMPARE(notInCach.size(), 0); |
|
67 | 63 | |
@@ -69,38 +65,35 void TestVariable::testNotInCacheRangeList() | |||
|
69 | 65 | // 4: varTS < ts < varTE < te |
|
70 | 66 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
71 | 67 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
72 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
73 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
68 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
74 | 69 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
75 | 70 | QCOMPARE(notInCach.size(), 1); |
|
76 | 71 | notInCachRange = notInCach.first(); |
|
77 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
78 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
72 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRE)); | |
|
73 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
79 | 74 | |
|
80 | 75 | // 5: varTS < varTE < ts < te |
|
81 | 76 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}}; |
|
82 | 77 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
83 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
84 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
78 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
85 | 79 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
86 | 80 | QCOMPARE(notInCach.size(), 1); |
|
87 | 81 | notInCachRange = notInCach.first(); |
|
88 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
89 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
82 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
83 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
90 | 84 | |
|
91 | 85 | // 6: ts <varTS < varTE < te |
|
92 | 86 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
93 | 87 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
94 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
95 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
88 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
96 | 89 | notInCach = var.provideNotInCacheRangeList(sqp); |
|
97 | 90 | QCOMPARE(notInCach.size(), 2); |
|
98 | 91 | notInCachRange = notInCach.first(); |
|
99 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
100 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
92 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
93 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRS)); | |
|
101 | 94 | notInCachRange = notInCach[1]; |
|
102 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
103 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
95 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRE)); | |
|
96 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
104 | 97 | } |
|
105 | 98 | |
|
106 | 99 | |
@@ -109,13 +102,12 void TestVariable::testInCacheRangeList() | |||
|
109 | 102 | auto varRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
110 | 103 | auto varRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 40, 0}}; |
|
111 | 104 | |
|
112 | auto sqpR = SqpRange{static_cast<double>(varRS.toMSecsSinceEpoch()), | |
|
113 | static_cast<double>(varRE.toMSecsSinceEpoch())}; | |
|
105 | auto sqpR = SqpRange{DateUtils::secondsSinceEpoch(varRS), DateUtils::secondsSinceEpoch(varRE)}; | |
|
114 | 106 | |
|
115 | 107 | auto varCRS = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
116 | 108 | auto varCRE = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
117 | auto sqpCR = SqpRange{static_cast<double>(varCRS.toMSecsSinceEpoch()), | |
|
118 | static_cast<double>(varCRE.toMSecsSinceEpoch())}; | |
|
109 | auto sqpCR | |
|
110 | = SqpRange{DateUtils::secondsSinceEpoch(varCRS), DateUtils::secondsSinceEpoch(varCRE)}; | |
|
119 | 111 | |
|
120 | 112 | Variable var{"Var test", sqpR}; |
|
121 | 113 | var.setCacheRange(sqpCR); |
@@ -123,8 +115,7 void TestVariable::testInCacheRangeList() | |||
|
123 | 115 | // 1: [ts,te] < varTS |
|
124 | 116 | auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
125 | 117 | auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
126 | auto sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
127 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
118 | auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
128 | 119 | |
|
129 | 120 | auto notInCach = var.provideInCacheRangeList(sqp); |
|
130 | 121 | |
@@ -133,54 +124,49 void TestVariable::testInCacheRangeList() | |||
|
133 | 124 | // 2: ts < varTS < te < varTE |
|
134 | 125 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
135 | 126 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
136 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
137 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
127 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
138 | 128 | notInCach = var.provideInCacheRangeList(sqp); |
|
139 | 129 | QCOMPARE(notInCach.size(), 1); |
|
140 | 130 | auto notInCachRange = notInCach.first(); |
|
141 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
142 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
131 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRS)); | |
|
132 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
143 | 133 | |
|
144 | 134 | // 3: varTS < ts < te < varTE |
|
145 | 135 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
146 | 136 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
147 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
148 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
137 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
149 | 138 | notInCach = var.provideInCacheRangeList(sqp); |
|
150 | 139 | QCOMPARE(notInCach.size(), 1); |
|
151 | 140 | notInCachRange = notInCach.first(); |
|
152 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
153 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
141 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
142 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
154 | 143 | |
|
155 | 144 | // 4: varTS < ts < varTE < te |
|
156 | 145 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 20, 0}}; |
|
157 | 146 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
158 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
159 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
147 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
160 | 148 | notInCach = var.provideInCacheRangeList(sqp); |
|
161 | 149 | QCOMPARE(notInCach.size(), 1); |
|
162 | 150 | notInCachRange = notInCach.first(); |
|
163 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
164 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
151 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
152 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRE)); | |
|
165 | 153 | |
|
166 | 154 | // 5: varTS < varTE < ts < te |
|
167 | 155 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 20, 0}}; |
|
168 | 156 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
169 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
170 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
157 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
171 | 158 | notInCach = var.provideInCacheRangeList(sqp); |
|
172 | 159 | QCOMPARE(notInCach.size(), 0); |
|
173 | 160 | |
|
174 | 161 | // 6: ts <varTS < varTE < te |
|
175 | 162 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
176 | 163 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
177 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
178 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
164 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
179 | 165 | notInCach = var.provideInCacheRangeList(sqp); |
|
180 | 166 | QCOMPARE(notInCach.size(), 1); |
|
181 | 167 | notInCachRange = notInCach.first(); |
|
182 |
QCOMPARE(notInCachRange.m_TStart, |
|
|
183 |
QCOMPARE(notInCachRange.m_TEnd, |
|
|
168 | QCOMPARE(notInCachRange.m_TStart, DateUtils::secondsSinceEpoch(varCRS)); | |
|
169 | QCOMPARE(notInCachRange.m_TEnd, DateUtils::secondsSinceEpoch(varCRE)); | |
|
184 | 170 | } |
|
185 | 171 | |
|
186 | 172 |
@@ -22,18 +22,15 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||
|
22 | 22 | |
|
23 | 23 | auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
24 | 24 | auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
25 | auto sqp0 = SqpRange{static_cast<double>(ts0.toMSecsSinceEpoch()), | |
|
26 | static_cast<double>(te0.toMSecsSinceEpoch())}; | |
|
25 | auto sqp0 = SqpRange{DateUtils::secondsSinceEpoch(ts0), DateUtils::secondsSinceEpoch(te0)}; | |
|
27 | 26 | |
|
28 | 27 | auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; |
|
29 | 28 | auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}}; |
|
30 | auto sqp1 = SqpRange{static_cast<double>(ts1.toMSecsSinceEpoch()), | |
|
31 | static_cast<double>(te1.toMSecsSinceEpoch())}; | |
|
29 | auto sqp1 = SqpRange{DateUtils::secondsSinceEpoch(ts1), DateUtils::secondsSinceEpoch(te1)}; | |
|
32 | 30 | |
|
33 | 31 | auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}}; |
|
34 | 32 | auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; |
|
35 | auto sqp2 = SqpRange{static_cast<double>(ts2.toMSecsSinceEpoch()), | |
|
36 | static_cast<double>(te2.toMSecsSinceEpoch())}; | |
|
33 | auto sqp2 = SqpRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)}; | |
|
37 | 34 | |
|
38 | 35 | auto var0 = std::make_shared<Variable>("", sqp0); |
|
39 | 36 | |
@@ -44,210 +41,197 void TestVariableCacheController::testProvideNotInCacheDateTimeList() | |||
|
44 | 41 | // first case [ts,te] < ts0 |
|
45 | 42 | auto ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
46 | 43 | auto te = QDateTime{QDate{2017, 01, 01}, QTime{2, 1, 0, 0}}; |
|
47 | auto sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
48 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
44 | auto sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
49 | 45 | |
|
50 | 46 | |
|
51 | 47 | auto notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
52 | 48 | |
|
53 | 49 | QCOMPARE(notInCach.size(), 1); |
|
54 | 50 | auto notInCacheSqp = notInCach.first(); |
|
55 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
56 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
51 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
52 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
57 | 53 | |
|
58 | 54 | |
|
59 | 55 | // second case ts < ts0 && ts0 < te <= te0 |
|
60 | 56 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
61 | 57 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
62 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
63 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
58 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
64 | 59 | |
|
65 | 60 | |
|
66 | 61 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
67 | 62 | |
|
68 | 63 | QCOMPARE(notInCach.size(), 1); |
|
69 | 64 | notInCacheSqp = notInCach.first(); |
|
70 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
71 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
65 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
66 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0)); | |
|
72 | 67 | |
|
73 | 68 | // 3th case ts < ts0 && te0 < te <= ts1 |
|
74 | 69 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
75 | 70 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
76 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
77 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
71 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
78 | 72 | |
|
79 | 73 | |
|
80 | 74 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
81 | 75 | |
|
82 | 76 | QCOMPARE(notInCach.size(), 2); |
|
83 | 77 | notInCacheSqp = notInCach.first(); |
|
84 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
85 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
78 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
79 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0)); | |
|
86 | 80 | |
|
87 | 81 | notInCacheSqp = notInCach.at(1); |
|
88 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
89 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
82 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); | |
|
83 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
90 | 84 | |
|
91 | 85 | // 4th case ts < ts0 && ts1 < te <= te1 |
|
92 | 86 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
93 | 87 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}}; |
|
94 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
95 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
88 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
96 | 89 | |
|
97 | 90 | |
|
98 | 91 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
99 | 92 | |
|
100 | 93 | QCOMPARE(notInCach.size(), 2); |
|
101 | 94 | notInCacheSqp = notInCach.first(); |
|
102 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
103 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
95 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
96 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0)); | |
|
104 | 97 | |
|
105 | 98 | notInCacheSqp = notInCach.at(1); |
|
106 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
107 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
99 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); | |
|
100 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); | |
|
108 | 101 | |
|
109 | 102 | // 5th case ts < ts0 && te3 < te |
|
110 | 103 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 0, 0, 0}}; |
|
111 | 104 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}}; |
|
112 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
113 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
105 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
114 | 106 | |
|
115 | 107 | |
|
116 | 108 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
117 | 109 | |
|
118 | 110 | QCOMPARE(notInCach.size(), 4); |
|
119 | 111 | notInCacheSqp = notInCach.first(); |
|
120 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
121 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
112 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
113 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts0)); | |
|
122 | 114 | |
|
123 | 115 | notInCacheSqp = notInCach.at(1); |
|
124 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
125 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
116 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); | |
|
117 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); | |
|
126 | 118 | |
|
127 | 119 | notInCacheSqp = notInCach.at(2); |
|
128 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
129 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
120 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te1)); | |
|
121 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts2)); | |
|
130 | 122 | |
|
131 | 123 | notInCacheSqp = notInCach.at(3); |
|
132 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
133 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
124 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te2)); | |
|
125 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
134 | 126 | |
|
135 | 127 | |
|
136 | 128 | // 6th case ts2 < ts |
|
137 | 129 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 45, 0, 0}}; |
|
138 | 130 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}}; |
|
139 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
140 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
131 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
141 | 132 | |
|
142 | 133 | |
|
143 | 134 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
144 | 135 | |
|
145 | 136 | QCOMPARE(notInCach.size(), 1); |
|
146 | 137 | notInCacheSqp = notInCach.first(); |
|
147 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
148 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
138 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
139 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
149 | 140 | |
|
150 | 141 | // 7th case ts = te0 && te < ts1 |
|
151 | 142 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
152 | 143 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
153 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
154 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
144 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
155 | 145 | |
|
156 | 146 | |
|
157 | 147 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
158 | 148 | |
|
159 | 149 | QCOMPARE(notInCach.size(), 1); |
|
160 | 150 | notInCacheSqp = notInCach.first(); |
|
161 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
162 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
151 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); | |
|
152 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
163 | 153 | |
|
164 | 154 | // 8th case ts0 < ts < te0 && te < ts1 |
|
165 | 155 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
166 | 156 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
167 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
168 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
157 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
169 | 158 | |
|
170 | 159 | |
|
171 | 160 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
172 | 161 | |
|
173 | 162 | QCOMPARE(notInCach.size(), 1); |
|
174 | 163 | notInCacheSqp = notInCach.first(); |
|
175 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
176 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
164 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); | |
|
165 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
177 | 166 | |
|
178 | 167 | // 9th case ts0 < ts < te0 && ts1 < te < te1 |
|
179 | 168 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 30, 0}}; |
|
180 | 169 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 7, 0, 0}}; |
|
181 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
182 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
170 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
183 | 171 | |
|
184 | 172 | |
|
185 | 173 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
186 | 174 | |
|
187 | 175 | QCOMPARE(notInCach.size(), 1); |
|
188 | 176 | notInCacheSqp = notInCach.first(); |
|
189 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
190 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
177 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te0)); | |
|
178 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); | |
|
191 | 179 | |
|
192 | 180 | // 10th case te1 < ts < te < ts2 |
|
193 | 181 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 9, 0, 0}}; |
|
194 | 182 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}}; |
|
195 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
196 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
183 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
197 | 184 | |
|
198 | 185 | |
|
199 | 186 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
200 | 187 | |
|
201 | 188 | QCOMPARE(notInCach.size(), 1); |
|
202 | 189 | notInCacheSqp = notInCach.first(); |
|
203 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
204 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
190 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
191 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
205 | 192 | |
|
206 | 193 | // 11th case te0 < ts < ts1 && te3 < te |
|
207 | 194 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
208 | 195 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 47, 0, 0}}; |
|
209 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
210 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
196 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
211 | 197 | |
|
212 | 198 | |
|
213 | 199 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
214 | 200 | |
|
215 | 201 | QCOMPARE(notInCach.size(), 3); |
|
216 | 202 | notInCacheSqp = notInCach.first(); |
|
217 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
218 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
203 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
204 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); | |
|
219 | 205 | |
|
220 | 206 | notInCacheSqp = notInCach.at(1); |
|
221 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
222 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
207 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te1)); | |
|
208 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts2)); | |
|
223 | 209 | |
|
224 | 210 | notInCacheSqp = notInCach.at(2); |
|
225 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
226 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
211 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te2)); | |
|
212 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
227 | 213 | |
|
228 | 214 | // 12th case te0 < ts < ts1 && te3 < te |
|
229 | 215 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 5, 0, 0}}; |
|
230 | 216 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 10, 0, 0}}; |
|
231 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
232 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
217 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
233 | 218 | |
|
234 | 219 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
235 | 220 | |
|
236 | 221 | QCOMPARE(notInCach.size(), 2); |
|
237 | 222 | notInCacheSqp = notInCach.first(); |
|
238 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
239 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
223 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(ts)); | |
|
224 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(ts1)); | |
|
240 | 225 | |
|
241 | 226 | notInCacheSqp = notInCach.at(1); |
|
242 |
QCOMPARE(notInCacheSqp.m_TStart, |
|
|
243 |
QCOMPARE(notInCacheSqp.m_TEnd, |
|
|
227 | QCOMPARE(notInCacheSqp.m_TStart, DateUtils::secondsSinceEpoch(te1)); | |
|
228 | QCOMPARE(notInCacheSqp.m_TEnd, DateUtils::secondsSinceEpoch(te)); | |
|
244 | 229 | |
|
245 | 230 | |
|
246 | 231 | // 12th case ts0 < ts < te0 |
|
247 | 232 | ts = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 10, 0}}; |
|
248 | 233 | te = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 50, 0}}; |
|
249 | sqp = SqpRange{static_cast<double>(ts.toMSecsSinceEpoch()), | |
|
250 | static_cast<double>(te.toMSecsSinceEpoch())}; | |
|
234 | sqp = SqpRange{DateUtils::secondsSinceEpoch(ts), DateUtils::secondsSinceEpoch(te)}; | |
|
251 | 235 | |
|
252 | 236 | notInCach = variableCacheController.provideNotInCacheDateTimeList(var0, sqp); |
|
253 | 237 | QCOMPARE(notInCach.size(), 0); |
@@ -260,33 +244,27 void TestVariableCacheController::testAddDateTime() | |||
|
260 | 244 | |
|
261 | 245 | auto ts0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 3, 0, 0}}; |
|
262 | 246 | auto te0 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
263 | auto sqp0 = SqpRange{static_cast<double>(ts0.toMSecsSinceEpoch()), | |
|
264 | static_cast<double>(te0.toMSecsSinceEpoch())}; | |
|
247 | auto sqp0 = SqpRange{DateUtils::secondsSinceEpoch(ts0), DateUtils::secondsSinceEpoch(te0)}; | |
|
265 | 248 | |
|
266 | 249 | auto ts1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; |
|
267 | 250 | auto te1 = QDateTime{QDate{2017, 01, 01}, QTime{2, 8, 0, 0}}; |
|
268 | auto sqp1 = SqpRange{static_cast<double>(ts1.toMSecsSinceEpoch()), | |
|
269 | static_cast<double>(te1.toMSecsSinceEpoch())}; | |
|
251 | auto sqp1 = SqpRange{DateUtils::secondsSinceEpoch(ts1), DateUtils::secondsSinceEpoch(te1)}; | |
|
270 | 252 | |
|
271 | 253 | auto ts2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 18, 0, 0}}; |
|
272 | 254 | auto te2 = QDateTime{QDate{2017, 01, 01}, QTime{2, 20, 0, 0}}; |
|
273 | auto sqp2 = SqpRange{static_cast<double>(ts2.toMSecsSinceEpoch()), | |
|
274 | static_cast<double>(te2.toMSecsSinceEpoch())}; | |
|
255 | auto sqp2 = SqpRange{DateUtils::secondsSinceEpoch(ts2), DateUtils::secondsSinceEpoch(te2)}; | |
|
275 | 256 | |
|
276 | 257 | auto ts01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
277 | 258 | auto te01 = QDateTime{QDate{2017, 01, 01}, QTime{2, 6, 0, 0}}; |
|
278 | auto sqp01 = SqpRange{static_cast<double>(ts01.toMSecsSinceEpoch()), | |
|
279 | static_cast<double>(te01.toMSecsSinceEpoch())}; | |
|
259 | auto sqp01 = SqpRange{DateUtils::secondsSinceEpoch(ts01), DateUtils::secondsSinceEpoch(te01)}; | |
|
280 | 260 | |
|
281 | 261 | auto ts3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 14, 0, 0}}; |
|
282 | 262 | auto te3 = QDateTime{QDate{2017, 01, 01}, QTime{2, 16, 0, 0}}; |
|
283 | auto sqp3 = SqpRange{static_cast<double>(ts3.toMSecsSinceEpoch()), | |
|
284 | static_cast<double>(te3.toMSecsSinceEpoch())}; | |
|
263 | auto sqp3 = SqpRange{DateUtils::secondsSinceEpoch(ts3), DateUtils::secondsSinceEpoch(te3)}; | |
|
285 | 264 | |
|
286 | 265 | auto ts03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 4, 0, 0}}; |
|
287 | 266 | auto te03 = QDateTime{QDate{2017, 01, 01}, QTime{2, 22, 0, 0}}; |
|
288 | auto sqp03 = SqpRange{static_cast<double>(ts03.toMSecsSinceEpoch()), | |
|
289 | static_cast<double>(te03.toMSecsSinceEpoch())}; | |
|
267 | auto sqp03 = SqpRange{DateUtils::secondsSinceEpoch(ts03), DateUtils::secondsSinceEpoch(te03)}; | |
|
290 | 268 | |
|
291 | 269 | |
|
292 | 270 | auto var0 = std::make_shared<Variable>("", sqp0); |
@@ -297,28 +275,28 void TestVariableCacheController::testAddDateTime() | |||
|
297 | 275 | auto dateCacheList = variableCacheController.dateCacheList(var0); |
|
298 | 276 | QCOMPARE(dateCacheList.count(), 1); |
|
299 | 277 | auto dateCache = dateCacheList.at(0); |
|
300 |
QCOMPARE(dateCache.m_TStart, |
|
|
301 |
QCOMPARE(dateCache.m_TEnd, |
|
|
278 | QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); | |
|
279 | QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te0)); | |
|
302 | 280 | |
|
303 | 281 | // 2nd case: add a second interval : sqp1 > sqp0 |
|
304 | 282 | variableCacheController.addDateTime(var0, sqp1); |
|
305 | 283 | dateCacheList = variableCacheController.dateCacheList(var0); |
|
306 | 284 | QCOMPARE(dateCacheList.count(), 2); |
|
307 | 285 | dateCache = dateCacheList.at(0); |
|
308 |
QCOMPARE(dateCache.m_TStart, |
|
|
309 |
QCOMPARE(dateCache.m_TEnd, |
|
|
286 | QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); | |
|
287 | QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te0)); | |
|
310 | 288 | |
|
311 | 289 | dateCache = dateCacheList.at(1); |
|
312 |
QCOMPARE(dateCache.m_TStart, |
|
|
313 |
QCOMPARE(dateCache.m_TEnd, |
|
|
290 | QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts1)); | |
|
291 | QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te1)); | |
|
314 | 292 | |
|
315 | 293 | // 3th case: merge sqp0 & sqp1 with sqp01 |
|
316 | 294 | variableCacheController.addDateTime(var0, sqp01); |
|
317 | 295 | dateCacheList = variableCacheController.dateCacheList(var0); |
|
318 | 296 | QCOMPARE(dateCacheList.count(), 1); |
|
319 | 297 | dateCache = dateCacheList.at(0); |
|
320 |
QCOMPARE(dateCache.m_TStart, |
|
|
321 |
QCOMPARE(dateCache.m_TEnd, |
|
|
298 | QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); | |
|
299 | QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te1)); | |
|
322 | 300 | |
|
323 | 301 | |
|
324 | 302 | // 4th case: add a second interval : sqp1 > sqp0 |
@@ -327,16 +305,16 void TestVariableCacheController::testAddDateTime() | |||
|
327 | 305 | dateCacheList = variableCacheController.dateCacheList(var0); |
|
328 | 306 | QCOMPARE(dateCacheList.count(), 3); |
|
329 | 307 | dateCache = dateCacheList.at(0); |
|
330 |
QCOMPARE(dateCache.m_TStart, |
|
|
331 |
QCOMPARE(dateCache.m_TEnd, |
|
|
308 | QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); | |
|
309 | QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te1)); | |
|
332 | 310 | |
|
333 | 311 | dateCache = dateCacheList.at(1); |
|
334 |
QCOMPARE(dateCache.m_TStart, |
|
|
335 |
QCOMPARE(dateCache.m_TEnd, |
|
|
312 | QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts3)); | |
|
313 | QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te3)); | |
|
336 | 314 | |
|
337 | 315 | dateCache = dateCacheList.at(2); |
|
338 |
QCOMPARE(dateCache.m_TStart, |
|
|
339 |
QCOMPARE(dateCache.m_TEnd, |
|
|
316 | QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts2)); | |
|
317 | QCOMPARE(dateCache.m_TEnd, DateUtils::secondsSinceEpoch(te2)); | |
|
340 | 318 | |
|
341 | 319 | |
|
342 | 320 | // 5th case: merge all interval |
@@ -344,8 +322,8 void TestVariableCacheController::testAddDateTime() | |||
|
344 | 322 | dateCacheList = variableCacheController.dateCacheList(var0); |
|
345 | 323 | QCOMPARE(dateCacheList.count(), 1); |
|
346 | 324 | dateCache = dateCacheList.at(0); |
|
347 |
QCOMPARE(dateCache.m_TStart, |
|
|
348 |
QCOMPARE(dateCache.m_TEnd, |
|
|
325 | QCOMPARE(dateCache.m_TStart, DateUtils::secondsSinceEpoch(ts0)); | |
|
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 | 4 | # Ignore false positive relative to two class definitions in a same file |
|
5 | 5 | DataSourceItem\.h:\d+:.*IPSIS_S01.* |
|
6 | DataSeries\.h:\d+:.*IPSIS_S01.* | |
|
7 | DataSeriesIterator\.h:\d+:.*IPSIS_S01.* | |
|
6 | 8 | |
|
7 | 9 | # Ignore false positive relative to a template class |
|
8 | 10 | ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (D) |
@@ -11,6 +13,7 ArrayData\.h:\d+:.*IPSIS_S06.*found: (D) | |||
|
11 | 13 | ArrayData\.h:\d+:.*IPSIS_S06.*found: (Dim) |
|
12 | 14 | DataSeries\.h:\d+:.*IPSIS_S04_METHOD.*found: LOG_DataSeries |
|
13 | 15 | DataSeries\.h:\d+:.*IPSIS_S04_VARIABLE.* |
|
16 | DataSeries\.h:\d+:.*IPSIS_S04_NAMESPACE.*found: (dataseries_detail) | |
|
14 | 17 | |
|
15 | 18 | # Ignore false positive relative to iterators |
|
16 | 19 | ArrayData\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (forward_iterator_tag) |
@@ -27,16 +30,20 ArrayData\.h:\d+:.*IPSIS_S06.*found: (ptrdiff_t) | |||
|
27 | 30 | ArrayData\.h:\d+:.*IPSIS_S06.*found: (pointer) |
|
28 | 31 | ArrayData\.h:\d+:.*IPSIS_S06.*found: (reference) |
|
29 | 32 | ArrayData\.h:\d+:.*IPSIS_S06.*found: (value_type) |
|
30 | DataSeries\.h:\d+:.*IPSIS_S05.* | |
|
31 |
DataSeries\.h:\d+:.*IPSIS_S0 |
|
|
32 |
DataSeries\.h:\d+:.*IPSIS_S0 |
|
|
33 |
DataSeries\.h:\d+:.*IPSIS_S0 |
|
|
34 |
DataSeries\.h:\d+:.*IPSIS_S0 |
|
|
35 |
DataSeries\.h:\d+:.*IPSIS_S06.*found: ( |
|
|
36 |
DataSeries\.h:\d+:.*IPSIS_S06.*found: ( |
|
|
37 |
DataSeries\.h:\d+:.*IPSIS_S06.*found: (p |
|
|
38 |
DataSeries\.h:\d+:.*IPSIS_S06.*found: ( |
|
|
39 |
DataSeries\.h:\d+:.*IPSIS_S06.*found: ( |
|
|
33 | DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (forward_iterator_tag) | |
|
34 | DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (DataSeriesIteratorValue) | |
|
35 | DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (ptrdiff_t) | |
|
36 | DataSeriesIterator\.h:\d+:.*IPSIS_S04_VARIABLE.*found: (value_type) | |
|
37 | DataSeriesIterator\.h:\d+:.*IPSIS_S05.* | |
|
38 | DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (iterator_category) | |
|
39 | DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (forward_iterator_tag) | |
|
40 | DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (value_type) | |
|
41 | DataSeriesIterator\.h:\d+:.*IPSIS_S06.*found: (DataSeriesIteratorValue) | |
|
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 | 48 | # Ignore false positive relative to an alias |
|
42 | 49 | DataSourceItemAction\.h:\d+:.*IPSIS_S06.*found: (ExecuteFunction) |
General Comments 0
You need to be logged in to leave comments.
Login now