Mercurial > hg > svcore
comparison base/test/TestEventSeries.h @ 1617:bdc19a09a1f9 single-point
Minor tweaks, comments, span tests
author | Chris Cannam |
---|---|
date | Fri, 08 Mar 2019 11:15:59 +0000 |
parents | de446dd905e6 |
children | f594fd249473 |
comparison
equal
deleted
inserted
replaced
1616:de446dd905e6 | 1617:bdc19a09a1f9 |
---|---|
86 QCOMPARE(s.getEventsCovering(10), cover); | 86 QCOMPARE(s.getEventsCovering(10), cover); |
87 QCOMPARE(s.getEventsCovering(11), EventVector()); | 87 QCOMPARE(s.getEventsCovering(11), EventVector()); |
88 QCOMPARE(s.getEventsCovering(9), EventVector()); | 88 QCOMPARE(s.getEventsCovering(9), EventVector()); |
89 } | 89 } |
90 | 90 |
91 void singleEventSpan() { | |
92 | |
93 EventSeries s; | |
94 Event p(10, QString()); | |
95 s.add(p); | |
96 EventVector span; | |
97 span.push_back(p); | |
98 QCOMPARE(s.getEventsSpanning(10, 2), span); | |
99 QCOMPARE(s.getEventsSpanning(9, 2), span); | |
100 QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); | |
101 QCOMPARE(s.getEventsSpanning(7, 2), EventVector()); | |
102 QCOMPARE(s.getEventsSpanning(11, 2), EventVector()); | |
103 } | |
104 | |
105 void identicalEventsCover() { | |
106 | |
107 EventSeries s; | |
108 Event p(10, QString()); | |
109 s.add(p); | |
110 s.add(p); | |
111 | |
112 EventVector cover; | |
113 cover.push_back(p); | |
114 cover.push_back(p); | |
115 QCOMPARE(s.getEventsCovering(10), cover); | |
116 QCOMPARE(s.getEventsCovering(11), EventVector()); | |
117 QCOMPARE(s.getEventsCovering(9), EventVector()); | |
118 | |
119 s.remove(p); | |
120 cover.clear(); | |
121 cover.push_back(p); | |
122 QCOMPARE(s.getEventsCovering(10), cover); | |
123 QCOMPARE(s.getEventsCovering(11), EventVector()); | |
124 QCOMPARE(s.getEventsCovering(9), EventVector()); | |
125 } | |
126 | |
127 void identicalEventsSpan() { | |
128 | |
129 EventSeries s; | |
130 Event p(10, QString()); | |
131 s.add(p); | |
132 s.add(p); | |
133 | |
134 EventVector span; | |
135 span.push_back(p); | |
136 span.push_back(p); | |
137 QCOMPARE(s.getEventsSpanning(10, 2), span); | |
138 QCOMPARE(s.getEventsSpanning(9, 2), span); | |
139 QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); | |
140 QCOMPARE(s.getEventsSpanning(11, 2), EventVector()); | |
141 } | |
142 | |
91 void similarEventsCover() { | 143 void similarEventsCover() { |
92 | 144 |
93 EventSeries s; | 145 EventSeries s; |
94 Event a(10, QString("a")); | 146 Event a(10, QString("a")); |
95 Event b(10, QString("b")); | 147 Event b(10, QString("b")); |
99 cover.push_back(a); | 151 cover.push_back(a); |
100 cover.push_back(b); | 152 cover.push_back(b); |
101 QCOMPARE(s.getEventsCovering(10), cover); | 153 QCOMPARE(s.getEventsCovering(10), cover); |
102 QCOMPARE(s.getEventsCovering(11), EventVector()); | 154 QCOMPARE(s.getEventsCovering(11), EventVector()); |
103 QCOMPARE(s.getEventsCovering(9), EventVector()); | 155 QCOMPARE(s.getEventsCovering(9), EventVector()); |
156 } | |
157 | |
158 void similarEventsSpan() { | |
159 | |
160 EventSeries s; | |
161 Event a(10, QString("a")); | |
162 Event b(10, QString("b")); | |
163 s.add(a); | |
164 s.add(b); | |
165 EventVector span; | |
166 span.push_back(a); | |
167 span.push_back(b); | |
168 QCOMPARE(s.getEventsSpanning(10, 2), span); | |
169 QCOMPARE(s.getEventsSpanning(9, 2), span); | |
170 QCOMPARE(s.getEventsSpanning(11, 2), EventVector()); | |
171 QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); | |
104 } | 172 } |
105 | 173 |
106 void singleEventWithDurationCover() { | 174 void singleEventWithDurationCover() { |
107 | 175 |
108 EventSeries s; | 176 EventSeries s; |
115 QCOMPARE(s.getEventsCovering(29), cover); | 183 QCOMPARE(s.getEventsCovering(29), cover); |
116 QCOMPARE(s.getEventsCovering(30), EventVector()); | 184 QCOMPARE(s.getEventsCovering(30), EventVector()); |
117 QCOMPARE(s.getEventsCovering(9), EventVector()); | 185 QCOMPARE(s.getEventsCovering(9), EventVector()); |
118 } | 186 } |
119 | 187 |
120 void identicalEventsCover() { | 188 void singleEventWithDurationSpan() { |
121 | 189 |
122 EventSeries s; | 190 EventSeries s; |
123 Event p(10, QString()); | 191 Event p(10, 1.0, 20, QString()); |
124 s.add(p); | 192 s.add(p); |
125 s.add(p); | 193 EventVector span; |
126 | 194 span.push_back(p); |
127 EventVector cover; | 195 QCOMPARE(s.getEventsSpanning(9, 2), span); |
128 cover.push_back(p); | 196 QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); |
129 cover.push_back(p); | 197 QCOMPARE(s.getEventsSpanning(19, 4), span); |
130 QCOMPARE(s.getEventsCovering(10), cover); | 198 QCOMPARE(s.getEventsSpanning(29, 2), span); |
131 QCOMPARE(s.getEventsCovering(11), EventVector()); | 199 QCOMPARE(s.getEventsSpanning(30, 2), EventVector()); |
132 QCOMPARE(s.getEventsCovering(9), EventVector()); | 200 } |
133 | 201 |
134 s.remove(p); | |
135 cover.clear(); | |
136 cover.push_back(p); | |
137 QCOMPARE(s.getEventsCovering(10), cover); | |
138 QCOMPARE(s.getEventsCovering(11), EventVector()); | |
139 QCOMPARE(s.getEventsCovering(9), EventVector()); | |
140 } | |
141 | |
142 void identicalEventsWithDurationCover() { | 202 void identicalEventsWithDurationCover() { |
143 | 203 |
144 EventSeries s; | 204 EventSeries s; |
145 Event p(10, 1.0, 20, QString()); | 205 Event p(10, 1.0, 20, QString()); |
146 s.add(p); | 206 s.add(p); |
162 QCOMPARE(s.getEventsCovering(29), cover); | 222 QCOMPARE(s.getEventsCovering(29), cover); |
163 QCOMPARE(s.getEventsCovering(30), EventVector()); | 223 QCOMPARE(s.getEventsCovering(30), EventVector()); |
164 QCOMPARE(s.getEventsCovering(9), EventVector()); | 224 QCOMPARE(s.getEventsCovering(9), EventVector()); |
165 } | 225 } |
166 | 226 |
227 void identicalEventsWithDurationSpan() { | |
228 | |
229 EventSeries s; | |
230 Event p(10, 1.0, 20, QString()); | |
231 s.add(p); | |
232 s.add(p); | |
233 EventVector span; | |
234 span.push_back(p); | |
235 span.push_back(p); | |
236 QCOMPARE(s.getEventsSpanning(9, 2), span); | |
237 QCOMPARE(s.getEventsSpanning(10, 2), span); | |
238 QCOMPARE(s.getEventsSpanning(11, 2), span); | |
239 QCOMPARE(s.getEventsSpanning(29, 2), span); | |
240 QCOMPARE(s.getEventsSpanning(30, 2), EventVector()); | |
241 QCOMPARE(s.getEventsSpanning(8, 2), EventVector()); | |
242 } | |
243 | |
167 void multipleEventsCover() { | 244 void multipleEventsCover() { |
168 | 245 |
169 EventSeries s; | 246 EventSeries s; |
170 Event a(10, QString("a")); | 247 Event a(10, QString("a")); |
171 Event b(11, QString("b")); | 248 Event b(11, QString("b")); |
183 QCOMPARE(s.getEventsCovering(10), cover); | 260 QCOMPARE(s.getEventsCovering(10), cover); |
184 cover.clear(); | 261 cover.clear(); |
185 cover.push_back(c); | 262 cover.push_back(c); |
186 QCOMPARE(s.getEventsCovering(40), cover); | 263 QCOMPARE(s.getEventsCovering(40), cover); |
187 QCOMPARE(s.getEventsCovering(9), EventVector()); | 264 QCOMPARE(s.getEventsCovering(9), EventVector()); |
265 } | |
266 | |
267 void multipleEventsSpan() { | |
268 | |
269 EventSeries s; | |
270 Event a(10, QString("a")); | |
271 Event b(11, QString("b")); | |
272 Event c(40, QString("c")); | |
273 s.add(c); | |
274 s.add(a); | |
275 s.add(b); | |
276 EventVector span; | |
277 span.push_back(a); | |
278 span.push_back(b); | |
279 QCOMPARE(s.getEventsSpanning(10, 2), span); | |
280 span.clear(); | |
281 span.push_back(c); | |
282 QCOMPARE(s.getEventsSpanning(39, 3), span); | |
283 QCOMPARE(s.getEventsSpanning(9, 1), EventVector()); | |
284 QCOMPARE(s.getEventsSpanning(10, 0), EventVector()); | |
188 } | 285 } |
189 | 286 |
190 void disjointEventsWithDurationCover() { | 287 void disjointEventsWithDurationCover() { |
191 | 288 |
192 EventSeries s; | 289 EventSeries s; |