##// END OF EJS Templates
PR: Use DateUtils instead of static_cast
perrinel -
r593:552e9eaf7536
parent child
Show More
@@ -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
General Comments 0
You need to be logged in to leave comments. Login now