Chris@1407
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@1407
|
2
|
Chris@1407
|
3 /*
|
Chris@1407
|
4 Sonic Visualiser
|
Chris@1407
|
5 An audio file viewer and annotation editor.
|
Chris@1407
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@1407
|
7
|
Chris@1407
|
8 This program is free software; you can redistribute it and/or
|
Chris@1407
|
9 modify it under the terms of the GNU General Public License as
|
Chris@1407
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@1407
|
11 License, or (at your option) any later version. See the file
|
Chris@1407
|
12 COPYING included with this distribution for more information.
|
Chris@1407
|
13 */
|
Chris@1407
|
14
|
Chris@1407
|
15 #ifndef TEST_SCALE_TICK_INTERVALS_H
|
Chris@1407
|
16 #define TEST_SCALE_TICK_INTERVALS_H
|
Chris@1407
|
17
|
Chris@1407
|
18 #include "../ScaleTickIntervals.h"
|
Chris@1407
|
19
|
Chris@1407
|
20 #include <QObject>
|
Chris@1407
|
21 #include <QtTest>
|
Chris@1407
|
22 #include <QDir>
|
Chris@1407
|
23
|
Chris@1407
|
24 #include <iostream>
|
Chris@1407
|
25
|
Chris@1407
|
26 using namespace std;
|
Chris@1407
|
27
|
Chris@1407
|
28 class TestScaleTickIntervals : public QObject
|
Chris@1407
|
29 {
|
Chris@1407
|
30 Q_OBJECT
|
Chris@1407
|
31
|
Chris@1407
|
32 void printDiff(vector<ScaleTickIntervals::Tick> ticks,
|
Chris@1407
|
33 vector<ScaleTickIntervals::Tick> expected) {
|
Chris@1407
|
34
|
Chris@1407
|
35 cerr << "Have " << ticks.size() << " ticks, expected "
|
Chris@1407
|
36 << expected.size() << endl;
|
Chris@1411
|
37 for (int i = 0; i < int(ticks.size()); ++i) {
|
Chris@1411
|
38 cerr << i << ": have " << ticks[i].value << " \""
|
Chris@1411
|
39 << ticks[i].label << "\", expected ";
|
Chris@1411
|
40 if (i < int(expected.size())) {
|
Chris@1411
|
41 cerr << expected[i].value << " \"" << expected[i].label
|
Chris@1407
|
42 << "\"" << endl;
|
Chris@1411
|
43 } else {
|
Chris@1411
|
44 cerr << "(n/a)" << endl;
|
Chris@1407
|
45 }
|
Chris@1407
|
46 }
|
Chris@1407
|
47 }
|
Chris@1407
|
48
|
Chris@1407
|
49 void compareTicks(vector<ScaleTickIntervals::Tick> ticks,
|
Chris@1407
|
50 vector<ScaleTickIntervals::Tick> expected)
|
Chris@1407
|
51 {
|
Chris@1408
|
52 double eps = 1e-7;
|
Chris@1407
|
53 for (int i = 0; i < int(expected.size()); ++i) {
|
Chris@1407
|
54 if (i < int(ticks.size())) {
|
Chris@1407
|
55 if (ticks[i].label != expected[i].label ||
|
Chris@1408
|
56 fabs(ticks[i].value - expected[i].value) > eps) {
|
Chris@1407
|
57 printDiff(ticks, expected);
|
Chris@1407
|
58 }
|
Chris@1407
|
59 QCOMPARE(ticks[i].label, expected[i].label);
|
Chris@1407
|
60 QCOMPARE(ticks[i].value, expected[i].value);
|
Chris@1407
|
61 }
|
Chris@1407
|
62 }
|
Chris@1408
|
63 if (ticks.size() != expected.size()) {
|
Chris@1408
|
64 printDiff(ticks, expected);
|
Chris@1408
|
65 }
|
Chris@1407
|
66 QCOMPARE(ticks.size(), expected.size());
|
Chris@1407
|
67 }
|
Chris@1407
|
68
|
Chris@1407
|
69 private slots:
|
Chris@1407
|
70 void linear_0_1_10()
|
Chris@1407
|
71 {
|
Chris@1407
|
72 auto ticks = ScaleTickIntervals::linear({ 0, 1, 10 });
|
Chris@1407
|
73 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1409
|
74 { 0.0, "0.0" },
|
Chris@1409
|
75 { 0.1, "0.1" },
|
Chris@1409
|
76 { 0.2, "0.2" },
|
Chris@1409
|
77 { 0.3, "0.3" },
|
Chris@1409
|
78 { 0.4, "0.4" },
|
Chris@1409
|
79 { 0.5, "0.5" },
|
Chris@1409
|
80 { 0.6, "0.6" },
|
Chris@1409
|
81 { 0.7, "0.7" },
|
Chris@1409
|
82 { 0.8, "0.8" },
|
Chris@1409
|
83 { 0.9, "0.9" },
|
Chris@1409
|
84 { 1.0, "1.0" }
|
Chris@1409
|
85 };
|
Chris@1409
|
86 compareTicks(ticks.ticks, expected);
|
Chris@1409
|
87 }
|
Chris@1409
|
88
|
Chris@1409
|
89 void linear_0_5_5()
|
Chris@1409
|
90 {
|
Chris@1409
|
91 auto ticks = ScaleTickIntervals::linear({ 0, 5, 5 });
|
Chris@1410
|
92 // generally if we have some activity in the units column, we
|
Chris@1410
|
93 // should add .0 to satisfy the human worry that we aren't
|
Chris@1410
|
94 // being told the whole story...
|
Chris@1409
|
95 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1410
|
96 { 0, "0.0" },
|
Chris@1410
|
97 { 1, "1.0" },
|
Chris@1410
|
98 { 2, "2.0" },
|
Chris@1410
|
99 { 3, "3.0" },
|
Chris@1410
|
100 { 4, "4.0" },
|
Chris@1410
|
101 { 5, "5.0" },
|
Chris@1409
|
102 };
|
Chris@1409
|
103 compareTicks(ticks.ticks, expected);
|
Chris@1409
|
104 }
|
Chris@1409
|
105
|
Chris@1409
|
106 void linear_0_10_5()
|
Chris@1409
|
107 {
|
Chris@1409
|
108 auto ticks = ScaleTickIntervals::linear({ 0, 10, 5 });
|
Chris@1409
|
109 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1410
|
110 { 0, "0.0" },
|
Chris@1410
|
111 { 2, "2.0" },
|
Chris@1410
|
112 { 4, "4.0" },
|
Chris@1410
|
113 { 6, "6.0" },
|
Chris@1410
|
114 { 8, "8.0" },
|
Chris@1410
|
115 { 10, "10.0" }
|
Chris@1407
|
116 };
|
Chris@1407
|
117 compareTicks(ticks.ticks, expected);
|
Chris@1407
|
118 }
|
Chris@1407
|
119
|
Chris@1411
|
120 void linear_10_0_5()
|
Chris@1411
|
121 {
|
Chris@1411
|
122 auto ticks = ScaleTickIntervals::linear({ 10, 0, 5 });
|
Chris@1411
|
123 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1411
|
124 { 0, "0.0" },
|
Chris@1411
|
125 { 2, "2.0" },
|
Chris@1411
|
126 { 4, "4.0" },
|
Chris@1411
|
127 { 6, "6.0" },
|
Chris@1411
|
128 { 8, "8.0" },
|
Chris@1411
|
129 { 10, "10.0" }
|
Chris@1411
|
130 };
|
Chris@1411
|
131 compareTicks(ticks.ticks, expected);
|
Chris@1411
|
132 }
|
Chris@1411
|
133
|
Chris@1411
|
134 void linear_m10_0_5()
|
Chris@1411
|
135 {
|
Chris@1411
|
136 auto ticks = ScaleTickIntervals::linear({ -10, 0, 5 });
|
Chris@1411
|
137 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1411
|
138 { -10, "-10.0" },
|
Chris@1411
|
139 { -8, "-8.0" },
|
Chris@1411
|
140 { -6, "-6.0" },
|
Chris@1411
|
141 { -4, "-4.0" },
|
Chris@1411
|
142 { -2, "-2.0" },
|
Chris@1411
|
143 { 0, "0.0" }
|
Chris@1411
|
144 };
|
Chris@1411
|
145 compareTicks(ticks.ticks, expected);
|
Chris@1411
|
146 }
|
Chris@1411
|
147
|
Chris@1411
|
148 void linear_0_m10_5()
|
Chris@1411
|
149 {
|
Chris@1411
|
150 auto ticks = ScaleTickIntervals::linear({ 0, -10, 5 });
|
Chris@1411
|
151 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1411
|
152 { -10, "-10.0" },
|
Chris@1411
|
153 { -8, "-8.0" },
|
Chris@1411
|
154 { -6, "-6.0" },
|
Chris@1411
|
155 { -4, "-4.0" },
|
Chris@1411
|
156 { -2, "-2.0" },
|
Chris@1411
|
157 { 0, "0.0" }
|
Chris@1411
|
158 };
|
Chris@1411
|
159 compareTicks(ticks.ticks, expected);
|
Chris@1411
|
160 }
|
Chris@1411
|
161
|
Chris@1407
|
162 void linear_0_0p1_5()
|
Chris@1407
|
163 {
|
Chris@1407
|
164 auto ticks = ScaleTickIntervals::linear({ 0, 0.1, 5 });
|
Chris@1407
|
165 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1409
|
166 { 0.00, "0.00" },
|
Chris@1407
|
167 { 0.02, "0.02" },
|
Chris@1407
|
168 { 0.04, "0.04" },
|
Chris@1407
|
169 { 0.06, "0.06" },
|
Chris@1407
|
170 { 0.08, "0.08" },
|
Chris@1409
|
171 { 0.10, "0.10" }
|
Chris@1407
|
172 };
|
Chris@1407
|
173 compareTicks(ticks.ticks, expected);
|
Chris@1407
|
174 }
|
Chris@1407
|
175
|
Chris@1407
|
176 void linear_0_0p01_5()
|
Chris@1407
|
177 {
|
Chris@1407
|
178 auto ticks = ScaleTickIntervals::linear({ 0, 0.01, 5 });
|
Chris@1407
|
179 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1409
|
180 { 0.000, "0.000" },
|
Chris@1407
|
181 { 0.002, "0.002" },
|
Chris@1407
|
182 { 0.004, "0.004" },
|
Chris@1407
|
183 { 0.006, "0.006" },
|
Chris@1407
|
184 { 0.008, "0.008" },
|
Chris@1409
|
185 { 0.010, "0.010" }
|
Chris@1409
|
186 };
|
Chris@1409
|
187 compareTicks(ticks.ticks, expected);
|
Chris@1409
|
188 }
|
Chris@1409
|
189
|
Chris@1409
|
190 void linear_0_0p005_5()
|
Chris@1409
|
191 {
|
Chris@1409
|
192 auto ticks = ScaleTickIntervals::linear({ 0, 0.005, 5 });
|
Chris@1409
|
193 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1409
|
194 { 0.000, "0.000" },
|
Chris@1409
|
195 { 0.001, "0.001" },
|
Chris@1409
|
196 { 0.002, "0.002" },
|
Chris@1409
|
197 { 0.003, "0.003" },
|
Chris@1409
|
198 { 0.004, "0.004" },
|
Chris@1409
|
199 { 0.005, "0.005" }
|
Chris@1407
|
200 };
|
Chris@1407
|
201 compareTicks(ticks.ticks, expected);
|
Chris@1407
|
202 }
|
Chris@1407
|
203
|
Chris@1407
|
204 void linear_0_0p001_5()
|
Chris@1407
|
205 {
|
Chris@1407
|
206 auto ticks = ScaleTickIntervals::linear({ 0, 0.001, 5 });
|
Chris@1407
|
207 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1409
|
208 { 0.0000, "0.0e+00" },
|
Chris@1407
|
209 { 0.0002, "2.0e-04" },
|
Chris@1407
|
210 { 0.0004, "4.0e-04" },
|
Chris@1407
|
211 { 0.0006, "6.0e-04" },
|
Chris@1407
|
212 { 0.0008, "8.0e-04" },
|
Chris@1409
|
213 { 0.0010, "1.0e-03" }
|
Chris@1407
|
214 };
|
Chris@1407
|
215 compareTicks(ticks.ticks, expected);
|
Chris@1407
|
216 }
|
Chris@1407
|
217
|
Chris@1407
|
218 void linear_1_1p001_5()
|
Chris@1407
|
219 {
|
Chris@1407
|
220 auto ticks = ScaleTickIntervals::linear({ 1, 1.001, 5 });
|
Chris@1407
|
221 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1409
|
222 { 1.0000, "1.0000" },
|
Chris@1407
|
223 { 1.0002, "1.0002" },
|
Chris@1407
|
224 { 1.0004, "1.0004" },
|
Chris@1407
|
225 { 1.0006, "1.0006" },
|
Chris@1407
|
226 { 1.0008, "1.0008" },
|
Chris@1409
|
227 { 1.0010, "1.0010" }
|
Chris@1409
|
228 };
|
Chris@1409
|
229 compareTicks(ticks.ticks, expected);
|
Chris@1409
|
230 }
|
Chris@1409
|
231
|
Chris@1413
|
232 void linear_0p001_1_5()
|
Chris@1413
|
233 {
|
Chris@1413
|
234 auto ticks = ScaleTickIntervals::linear({ 0.001, 1, 5 });
|
Chris@1413
|
235 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1413
|
236 { 0.1, "0.1" },
|
Chris@1413
|
237 { 0.3, "0.3" },
|
Chris@1413
|
238 { 0.5, "0.5" },
|
Chris@1413
|
239 { 0.7, "0.7" },
|
Chris@1413
|
240 { 0.9, "0.9" },
|
Chris@1413
|
241 };
|
Chris@1413
|
242 compareTicks(ticks.ticks, expected);
|
Chris@1413
|
243 }
|
Chris@1413
|
244
|
Chris@1409
|
245 void linear_10000_10010_5()
|
Chris@1409
|
246 {
|
Chris@1409
|
247 auto ticks = ScaleTickIntervals::linear({ 10000, 10010, 5 });
|
Chris@1409
|
248 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1410
|
249 { 10000, "10000.0" },
|
Chris@1410
|
250 { 10002, "10002.0" },
|
Chris@1410
|
251 { 10004, "10004.0" },
|
Chris@1410
|
252 { 10006, "10006.0" },
|
Chris@1410
|
253 { 10008, "10008.0" },
|
Chris@1410
|
254 { 10010, "10010.0" },
|
Chris@1409
|
255 };
|
Chris@1409
|
256 compareTicks(ticks.ticks, expected);
|
Chris@1409
|
257 }
|
Chris@1409
|
258
|
Chris@1409
|
259 void linear_10000_20000_5()
|
Chris@1409
|
260 {
|
Chris@1409
|
261 auto ticks = ScaleTickIntervals::linear({ 10000, 20000, 5 });
|
Chris@1409
|
262 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1409
|
263 { 10000, "10000" },
|
Chris@1409
|
264 { 12000, "12000" },
|
Chris@1409
|
265 { 14000, "14000" },
|
Chris@1409
|
266 { 16000, "16000" },
|
Chris@1409
|
267 { 18000, "18000" },
|
Chris@1409
|
268 { 20000, "20000" },
|
Chris@1409
|
269 };
|
Chris@1409
|
270 compareTicks(ticks.ticks, expected);
|
Chris@1409
|
271 }
|
Chris@1409
|
272
|
Chris@1409
|
273 void linear_m1_1_10()
|
Chris@1409
|
274 {
|
Chris@1409
|
275 auto ticks = ScaleTickIntervals::linear({ -1, 1, 10 });
|
Chris@1409
|
276 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1409
|
277 { -1.0, "-1.0" },
|
Chris@1409
|
278 { -0.8, "-0.8" },
|
Chris@1409
|
279 { -0.6, "-0.6" },
|
Chris@1409
|
280 { -0.4, "-0.4" },
|
Chris@1409
|
281 { -0.2, "-0.2" },
|
Chris@1409
|
282 { 0.0, "0.0" },
|
Chris@1409
|
283 { 0.2, "0.2" },
|
Chris@1409
|
284 { 0.4, "0.4" },
|
Chris@1409
|
285 { 0.6, "0.6" },
|
Chris@1409
|
286 { 0.8, "0.8" },
|
Chris@1409
|
287 { 1.0, "1.0" }
|
Chris@1407
|
288 };
|
Chris@1407
|
289 compareTicks(ticks.ticks, expected);
|
Chris@1407
|
290 }
|
Chris@1411
|
291
|
Chris@1411
|
292 void linear_221p23_623p7_57p4()
|
Chris@1411
|
293 {
|
Chris@1411
|
294 auto ticks = ScaleTickIntervals::linear({ 221.23, 623.7, 4 });
|
Chris@1411
|
295 // only 4 ticks, not 5, because none of the rounded tick
|
Chris@1411
|
296 // values lies on an end value
|
Chris@1411
|
297 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1411
|
298 { 230, "230" },
|
Chris@1411
|
299 { 330, "330" },
|
Chris@1411
|
300 { 430, "430" },
|
Chris@1411
|
301 { 530, "530" },
|
Chris@1411
|
302 };
|
Chris@1411
|
303 compareTicks(ticks.ticks, expected);
|
Chris@1411
|
304 }
|
Chris@1411
|
305
|
Chris@1412
|
306 void linear_sqrt2_pi_7()
|
Chris@1412
|
307 {
|
Chris@1412
|
308 auto ticks = ScaleTickIntervals::linear({ sqrt(2.0), M_PI, 7 });
|
Chris@1412
|
309 // This would be better in steps of 0.25, but we only round to
|
Chris@1412
|
310 // integral powers of ten
|
Chris@1412
|
311 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1412
|
312 { 1.5, "1.5" },
|
Chris@1412
|
313 { 1.7, "1.7" },
|
Chris@1412
|
314 { 1.9, "1.9" },
|
Chris@1412
|
315 { 2.1, "2.1" },
|
Chris@1412
|
316 { 2.3, "2.3" },
|
Chris@1412
|
317 { 2.5, "2.5" },
|
Chris@1412
|
318 { 2.7, "2.7" },
|
Chris@1412
|
319 { 2.9, "2.9" },
|
Chris@1412
|
320 { 3.1, "3.1" },
|
Chris@1412
|
321 };
|
Chris@1412
|
322 compareTicks(ticks.ticks, expected);
|
Chris@1412
|
323 }
|
Chris@1412
|
324
|
Chris@1412
|
325 void linear_pi_avogadro_7()
|
Chris@1412
|
326 {
|
Chris@1412
|
327 auto ticks = ScaleTickIntervals::linear({ M_PI, 6.022140857e23, 7 });
|
Chris@1412
|
328 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1413
|
329 { 1e+21, "1.000e+21" },
|
Chris@1413
|
330 { 8.7e+22, "8.700e+22" },
|
Chris@1413
|
331 { 1.73e+23, "1.730e+23" },
|
Chris@1413
|
332 { 2.59e+23, "2.590e+23" },
|
Chris@1413
|
333 { 3.45e+23, "3.450e+23" },
|
Chris@1413
|
334 { 4.31e+23, "4.310e+23" },
|
Chris@1413
|
335 { 5.17e+23, "5.170e+23" },
|
Chris@1412
|
336 };
|
Chris@1412
|
337 compareTicks(ticks.ticks, expected);
|
Chris@1412
|
338 }
|
Chris@1412
|
339
|
Chris@1412
|
340 void linear_2_3_1()
|
Chris@1412
|
341 {
|
Chris@1412
|
342 auto ticks = ScaleTickIntervals::linear({ 2, 3, 1 });
|
Chris@1412
|
343 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1412
|
344 { 2.0, "2.0" },
|
Chris@1412
|
345 { 3.0, "3.0" }
|
Chris@1412
|
346 };
|
Chris@1412
|
347 compareTicks(ticks.ticks, expected);
|
Chris@1412
|
348 }
|
Chris@1412
|
349
|
Chris@1412
|
350 void linear_2_3_2()
|
Chris@1412
|
351 {
|
Chris@1412
|
352 auto ticks = ScaleTickIntervals::linear({ 2, 3, 2 });
|
Chris@1412
|
353 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1412
|
354 { 2.0, "2.0" },
|
Chris@1412
|
355 { 2.5, "2.5" },
|
Chris@1412
|
356 { 3.0, "3.0" }
|
Chris@1412
|
357 };
|
Chris@1412
|
358 compareTicks(ticks.ticks, expected);
|
Chris@1412
|
359 }
|
Chris@1412
|
360
|
Chris@1412
|
361 void linear_2_3_3()
|
Chris@1412
|
362 {
|
Chris@1412
|
363 auto ticks = ScaleTickIntervals::linear({ 2, 3, 3 });
|
Chris@1412
|
364 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1412
|
365 { 2.0, "2.0" },
|
Chris@1412
|
366 { 2.3, "2.3" },
|
Chris@1412
|
367 { 2.6, "2.6" },
|
Chris@1412
|
368 { 2.9, "2.9" }
|
Chris@1412
|
369 };
|
Chris@1412
|
370 compareTicks(ticks.ticks, expected);
|
Chris@1412
|
371 }
|
Chris@1412
|
372
|
Chris@1412
|
373 void linear_2_3_4()
|
Chris@1412
|
374 {
|
Chris@1412
|
375 auto ticks = ScaleTickIntervals::linear({ 2, 3, 4 });
|
Chris@1412
|
376 // This would be better in steps of 0.25, but we only round to
|
Chris@1412
|
377 // integral powers of ten
|
Chris@1412
|
378 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1412
|
379 { 2.0, "2.0" },
|
Chris@1412
|
380 { 2.3, "2.3" },
|
Chris@1412
|
381 { 2.6, "2.6" },
|
Chris@1412
|
382 { 2.9, "2.9" }
|
Chris@1412
|
383 };
|
Chris@1412
|
384 compareTicks(ticks.ticks, expected);
|
Chris@1412
|
385 }
|
Chris@1412
|
386
|
Chris@1412
|
387 void linear_2_3_5()
|
Chris@1412
|
388 {
|
Chris@1412
|
389 auto ticks = ScaleTickIntervals::linear({ 2, 3, 5 });
|
Chris@1412
|
390 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1412
|
391 { 2.0, "2.0" },
|
Chris@1412
|
392 { 2.2, "2.2" },
|
Chris@1412
|
393 { 2.4, "2.4" },
|
Chris@1412
|
394 { 2.6, "2.6" },
|
Chris@1412
|
395 { 2.8, "2.8" },
|
Chris@1412
|
396 { 3.0, "3.0" }
|
Chris@1412
|
397 };
|
Chris@1412
|
398 compareTicks(ticks.ticks, expected);
|
Chris@1412
|
399 }
|
Chris@1412
|
400
|
Chris@1412
|
401 void linear_2_3_6()
|
Chris@1412
|
402 {
|
Chris@1412
|
403 auto ticks = ScaleTickIntervals::linear({ 2, 3, 6 });
|
Chris@1412
|
404 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1412
|
405 { 2.0, "2.0" },
|
Chris@1412
|
406 { 2.2, "2.2" },
|
Chris@1412
|
407 { 2.4, "2.4" },
|
Chris@1412
|
408 { 2.6, "2.6" },
|
Chris@1412
|
409 { 2.8, "2.8" },
|
Chris@1412
|
410 { 3.0, "3.0" }
|
Chris@1412
|
411 };
|
Chris@1412
|
412 compareTicks(ticks.ticks, expected);
|
Chris@1412
|
413 }
|
Chris@1412
|
414
|
Chris@1411
|
415 void linear_1_1_10()
|
Chris@1411
|
416 {
|
Chris@1411
|
417 auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 });
|
Chris@1411
|
418 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1411
|
419 { 1.0, "1.0" }
|
Chris@1411
|
420 };
|
Chris@1411
|
421 compareTicks(ticks.ticks, expected);
|
Chris@1411
|
422 }
|
Chris@1411
|
423
|
Chris@1411
|
424 void linear_0_0_10()
|
Chris@1411
|
425 {
|
Chris@1411
|
426 auto ticks = ScaleTickIntervals::linear({ 0, 0, 10 });
|
Chris@1411
|
427 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1411
|
428 { 0.0, "0.0" }
|
Chris@1411
|
429 };
|
Chris@1411
|
430 compareTicks(ticks.ticks, expected);
|
Chris@1411
|
431 }
|
Chris@1411
|
432
|
Chris@1411
|
433 void linear_0_1_1()
|
Chris@1411
|
434 {
|
Chris@1411
|
435 auto ticks = ScaleTickIntervals::linear({ 0, 1, 1 });
|
Chris@1411
|
436 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1411
|
437 { 0.0, "0.0" },
|
Chris@1411
|
438 { 1.0, "1.0" }
|
Chris@1411
|
439 };
|
Chris@1411
|
440 compareTicks(ticks.ticks, expected);
|
Chris@1411
|
441 }
|
Chris@1411
|
442
|
Chris@1411
|
443 void linear_0_1_0()
|
Chris@1411
|
444 {
|
Chris@1411
|
445 auto ticks = ScaleTickIntervals::linear({ 0, 1, 0 });
|
Chris@1411
|
446 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1411
|
447 };
|
Chris@1411
|
448 compareTicks(ticks.ticks, expected);
|
Chris@1411
|
449 }
|
Chris@1411
|
450
|
Chris@1411
|
451 void linear_0_1_m1()
|
Chris@1411
|
452 {
|
Chris@1411
|
453 auto ticks = ScaleTickIntervals::linear({ 0, 1, -1 });
|
Chris@1411
|
454 vector<ScaleTickIntervals::Tick> expected {
|
Chris@1411
|
455 };
|
Chris@1411
|
456 compareTicks(ticks.ticks, expected);
|
Chris@1411
|
457 }
|
Chris@1407
|
458 };
|
Chris@1407
|
459
|
Chris@1407
|
460 #endif
|
Chris@1407
|
461
|
Chris@1407
|
462
|