comparison base/test/TestScaleTickIntervals.h @ 1417:359147a50853 scale-ticks

We don't need to return the tick instruction gubbins
author Chris Cannam
date Thu, 04 May 2017 13:32:42 +0100
parents 9a8995785827
children e7cb4fb2aee4
comparison
equal deleted inserted replaced
1416:9a8995785827 1417:359147a50853
44 cerr << "(n/a)" << endl; 44 cerr << "(n/a)" << endl;
45 } 45 }
46 } 46 }
47 } 47 }
48 48
49 void compareTicks(vector<ScaleTickIntervals::Tick> ticks, 49 void compareTicks(ScaleTickIntervals::Ticks ticks,
50 vector<ScaleTickIntervals::Tick> expected, 50 ScaleTickIntervals::Ticks expected,
51 bool fuzzier = false) 51 bool fuzzier = false)
52 { 52 {
53 double eps = 1e-7; 53 double eps = 1e-7;
54 for (int i = 0; i < int(expected.size()); ++i) { 54 for (int i = 0; i < int(expected.size()); ++i) {
55 if (i < int(ticks.size())) { 55 if (i < int(ticks.size())) {
81 81
82 private slots: 82 private slots:
83 void linear_0_1_10() 83 void linear_0_1_10()
84 { 84 {
85 auto ticks = ScaleTickIntervals::linear({ 0, 1, 10 }); 85 auto ticks = ScaleTickIntervals::linear({ 0, 1, 10 });
86 vector<ScaleTickIntervals::Tick> expected { 86 ScaleTickIntervals::Ticks expected {
87 { 0.0, "0.0" }, 87 { 0.0, "0.0" },
88 { 0.1, "0.1" }, 88 { 0.1, "0.1" },
89 { 0.2, "0.2" }, 89 { 0.2, "0.2" },
90 { 0.3, "0.3" }, 90 { 0.3, "0.3" },
91 { 0.4, "0.4" }, 91 { 0.4, "0.4" },
94 { 0.7, "0.7" }, 94 { 0.7, "0.7" },
95 { 0.8, "0.8" }, 95 { 0.8, "0.8" },
96 { 0.9, "0.9" }, 96 { 0.9, "0.9" },
97 { 1.0, "1.0" } 97 { 1.0, "1.0" }
98 }; 98 };
99 compareTicks(ticks.ticks, expected); 99 compareTicks(ticks, expected);
100 } 100 }
101 101
102 void linear_0_5_5() 102 void linear_0_5_5()
103 { 103 {
104 auto ticks = ScaleTickIntervals::linear({ 0, 5, 5 }); 104 auto ticks = ScaleTickIntervals::linear({ 0, 5, 5 });
105 vector<ScaleTickIntervals::Tick> expected { 105 ScaleTickIntervals::Ticks expected {
106 { 0, "0" }, 106 { 0, "0" },
107 { 1, "1" }, 107 { 1, "1" },
108 { 2, "2" }, 108 { 2, "2" },
109 { 3, "3" }, 109 { 3, "3" },
110 { 4, "4" }, 110 { 4, "4" },
111 { 5, "5" }, 111 { 5, "5" },
112 }; 112 };
113 compareTicks(ticks.ticks, expected); 113 compareTicks(ticks, expected);
114 } 114 }
115 115
116 void linear_0_10_5() 116 void linear_0_10_5()
117 { 117 {
118 auto ticks = ScaleTickIntervals::linear({ 0, 10, 5 }); 118 auto ticks = ScaleTickIntervals::linear({ 0, 10, 5 });
119 vector<ScaleTickIntervals::Tick> expected { 119 ScaleTickIntervals::Ticks expected {
120 { 0, "0" }, 120 { 0, "0" },
121 { 2, "2" }, 121 { 2, "2" },
122 { 4, "4" }, 122 { 4, "4" },
123 { 6, "6" }, 123 { 6, "6" },
124 { 8, "8" }, 124 { 8, "8" },
125 { 10, "10" } 125 { 10, "10" }
126 }; 126 };
127 compareTicks(ticks.ticks, expected); 127 compareTicks(ticks, expected);
128 } 128 }
129 129
130 void linear_10_0_5() 130 void linear_10_0_5()
131 { 131 {
132 auto ticks = ScaleTickIntervals::linear({ 10, 0, 5 }); 132 auto ticks = ScaleTickIntervals::linear({ 10, 0, 5 });
133 vector<ScaleTickIntervals::Tick> expected { 133 ScaleTickIntervals::Ticks expected {
134 { 0, "0" }, 134 { 0, "0" },
135 { 2, "2" }, 135 { 2, "2" },
136 { 4, "4" }, 136 { 4, "4" },
137 { 6, "6" }, 137 { 6, "6" },
138 { 8, "8" }, 138 { 8, "8" },
139 { 10, "10" } 139 { 10, "10" }
140 }; 140 };
141 compareTicks(ticks.ticks, expected); 141 compareTicks(ticks, expected);
142 } 142 }
143 143
144 void linear_m10_0_5() 144 void linear_m10_0_5()
145 { 145 {
146 auto ticks = ScaleTickIntervals::linear({ -10, 0, 5 }); 146 auto ticks = ScaleTickIntervals::linear({ -10, 0, 5 });
147 vector<ScaleTickIntervals::Tick> expected { 147 ScaleTickIntervals::Ticks expected {
148 { -10, "-10" }, 148 { -10, "-10" },
149 { -8, "-8" }, 149 { -8, "-8" },
150 { -6, "-6" }, 150 { -6, "-6" },
151 { -4, "-4" }, 151 { -4, "-4" },
152 { -2, "-2" }, 152 { -2, "-2" },
153 { 0, "0" } 153 { 0, "0" }
154 }; 154 };
155 compareTicks(ticks.ticks, expected); 155 compareTicks(ticks, expected);
156 } 156 }
157 157
158 void linear_0_m10_5() 158 void linear_0_m10_5()
159 { 159 {
160 auto ticks = ScaleTickIntervals::linear({ 0, -10, 5 }); 160 auto ticks = ScaleTickIntervals::linear({ 0, -10, 5 });
161 vector<ScaleTickIntervals::Tick> expected { 161 ScaleTickIntervals::Ticks expected {
162 { -10, "-10" }, 162 { -10, "-10" },
163 { -8, "-8" }, 163 { -8, "-8" },
164 { -6, "-6" }, 164 { -6, "-6" },
165 { -4, "-4" }, 165 { -4, "-4" },
166 { -2, "-2" }, 166 { -2, "-2" },
167 { 0, "0" } 167 { 0, "0" }
168 }; 168 };
169 compareTicks(ticks.ticks, expected); 169 compareTicks(ticks, expected);
170 } 170 }
171 171
172 void linear_0_0p1_5() 172 void linear_0_0p1_5()
173 { 173 {
174 auto ticks = ScaleTickIntervals::linear({ 0, 0.1, 5 }); 174 auto ticks = ScaleTickIntervals::linear({ 0, 0.1, 5 });
175 vector<ScaleTickIntervals::Tick> expected { 175 ScaleTickIntervals::Ticks expected {
176 { 0.00, "0.00" }, 176 { 0.00, "0.00" },
177 { 0.02, "0.02" }, 177 { 0.02, "0.02" },
178 { 0.04, "0.04" }, 178 { 0.04, "0.04" },
179 { 0.06, "0.06" }, 179 { 0.06, "0.06" },
180 { 0.08, "0.08" }, 180 { 0.08, "0.08" },
181 { 0.10, "0.10" } 181 { 0.10, "0.10" }
182 }; 182 };
183 compareTicks(ticks.ticks, expected); 183 compareTicks(ticks, expected);
184 } 184 }
185 185
186 void linear_0_0p01_5() 186 void linear_0_0p01_5()
187 { 187 {
188 auto ticks = ScaleTickIntervals::linear({ 0, 0.01, 5 }); 188 auto ticks = ScaleTickIntervals::linear({ 0, 0.01, 5 });
189 vector<ScaleTickIntervals::Tick> expected { 189 ScaleTickIntervals::Ticks expected {
190 { 0.000, "0.000" }, 190 { 0.000, "0.000" },
191 { 0.002, "0.002" }, 191 { 0.002, "0.002" },
192 { 0.004, "0.004" }, 192 { 0.004, "0.004" },
193 { 0.006, "0.006" }, 193 { 0.006, "0.006" },
194 { 0.008, "0.008" }, 194 { 0.008, "0.008" },
195 { 0.010, "0.010" } 195 { 0.010, "0.010" }
196 }; 196 };
197 compareTicks(ticks.ticks, expected); 197 compareTicks(ticks, expected);
198 } 198 }
199 199
200 void linear_0_0p005_5() 200 void linear_0_0p005_5()
201 { 201 {
202 auto ticks = ScaleTickIntervals::linear({ 0, 0.005, 5 }); 202 auto ticks = ScaleTickIntervals::linear({ 0, 0.005, 5 });
203 vector<ScaleTickIntervals::Tick> expected { 203 ScaleTickIntervals::Ticks expected {
204 { 0.000, "0.000" }, 204 { 0.000, "0.000" },
205 { 0.001, "0.001" }, 205 { 0.001, "0.001" },
206 { 0.002, "0.002" }, 206 { 0.002, "0.002" },
207 { 0.003, "0.003" }, 207 { 0.003, "0.003" },
208 { 0.004, "0.004" }, 208 { 0.004, "0.004" },
209 { 0.005, "0.005" } 209 { 0.005, "0.005" }
210 }; 210 };
211 compareTicks(ticks.ticks, expected); 211 compareTicks(ticks, expected);
212 } 212 }
213 213
214 void linear_0_0p001_5() 214 void linear_0_0p001_5()
215 { 215 {
216 auto ticks = ScaleTickIntervals::linear({ 0, 0.001, 5 }); 216 auto ticks = ScaleTickIntervals::linear({ 0, 0.001, 5 });
217 vector<ScaleTickIntervals::Tick> expected { 217 ScaleTickIntervals::Ticks expected {
218 { 0.0000, "0.0e+00" }, 218 { 0.0000, "0.0e+00" },
219 { 0.0002, "2.0e-04" }, 219 { 0.0002, "2.0e-04" },
220 { 0.0004, "4.0e-04" }, 220 { 0.0004, "4.0e-04" },
221 { 0.0006, "6.0e-04" }, 221 { 0.0006, "6.0e-04" },
222 { 0.0008, "8.0e-04" }, 222 { 0.0008, "8.0e-04" },
223 { 0.0010, "1.0e-03" } 223 { 0.0010, "1.0e-03" }
224 }; 224 };
225 compareTicks(ticks.ticks, expected); 225 compareTicks(ticks, expected);
226 } 226 }
227 227
228 void linear_1_1p001_5() 228 void linear_1_1p001_5()
229 { 229 {
230 auto ticks = ScaleTickIntervals::linear({ 1, 1.001, 5 }); 230 auto ticks = ScaleTickIntervals::linear({ 1, 1.001, 5 });
231 vector<ScaleTickIntervals::Tick> expected { 231 ScaleTickIntervals::Ticks expected {
232 { 1.0000, "1.0000" }, 232 { 1.0000, "1.0000" },
233 { 1.0002, "1.0002" }, 233 { 1.0002, "1.0002" },
234 { 1.0004, "1.0004" }, 234 { 1.0004, "1.0004" },
235 { 1.0006, "1.0006" }, 235 { 1.0006, "1.0006" },
236 { 1.0008, "1.0008" }, 236 { 1.0008, "1.0008" },
237 { 1.0010, "1.0010" } 237 { 1.0010, "1.0010" }
238 }; 238 };
239 compareTicks(ticks.ticks, expected); 239 compareTicks(ticks, expected);
240 } 240 }
241 241
242 void linear_0p001_1_5() 242 void linear_0p001_1_5()
243 { 243 {
244 auto ticks = ScaleTickIntervals::linear({ 0.001, 1, 5 }); 244 auto ticks = ScaleTickIntervals::linear({ 0.001, 1, 5 });
245 vector<ScaleTickIntervals::Tick> expected { 245 ScaleTickIntervals::Ticks expected {
246 { 0.1, "0.1" }, 246 { 0.1, "0.1" },
247 { 0.3, "0.3" }, 247 { 0.3, "0.3" },
248 { 0.5, "0.5" }, 248 { 0.5, "0.5" },
249 { 0.7, "0.7" }, 249 { 0.7, "0.7" },
250 { 0.9, "0.9" }, 250 { 0.9, "0.9" },
251 }; 251 };
252 compareTicks(ticks.ticks, expected); 252 compareTicks(ticks, expected);
253 } 253 }
254 254
255 void linear_10000_10010_5() 255 void linear_10000_10010_5()
256 { 256 {
257 auto ticks = ScaleTickIntervals::linear({ 10000, 10010, 5 }); 257 auto ticks = ScaleTickIntervals::linear({ 10000, 10010, 5 });
258 vector<ScaleTickIntervals::Tick> expected { 258 ScaleTickIntervals::Ticks expected {
259 { 10000, "10000" }, 259 { 10000, "10000" },
260 { 10002, "10002" }, 260 { 10002, "10002" },
261 { 10004, "10004" }, 261 { 10004, "10004" },
262 { 10006, "10006" }, 262 { 10006, "10006" },
263 { 10008, "10008" }, 263 { 10008, "10008" },
264 { 10010, "10010" }, 264 { 10010, "10010" },
265 }; 265 };
266 compareTicks(ticks.ticks, expected); 266 compareTicks(ticks, expected);
267 } 267 }
268 268
269 void linear_10000_20000_5() 269 void linear_10000_20000_5()
270 { 270 {
271 auto ticks = ScaleTickIntervals::linear({ 10000, 20000, 5 }); 271 auto ticks = ScaleTickIntervals::linear({ 10000, 20000, 5 });
272 vector<ScaleTickIntervals::Tick> expected { 272 ScaleTickIntervals::Ticks expected {
273 { 10000, "10000" }, 273 { 10000, "10000" },
274 { 12000, "12000" }, 274 { 12000, "12000" },
275 { 14000, "14000" }, 275 { 14000, "14000" },
276 { 16000, "16000" }, 276 { 16000, "16000" },
277 { 18000, "18000" }, 277 { 18000, "18000" },
278 { 20000, "20000" }, 278 { 20000, "20000" },
279 }; 279 };
280 compareTicks(ticks.ticks, expected); 280 compareTicks(ticks, expected);
281 } 281 }
282 282
283 void linear_m1_1_10() 283 void linear_m1_1_10()
284 { 284 {
285 auto ticks = ScaleTickIntervals::linear({ -1, 1, 10 }); 285 auto ticks = ScaleTickIntervals::linear({ -1, 1, 10 });
286 vector<ScaleTickIntervals::Tick> expected { 286 ScaleTickIntervals::Ticks expected {
287 { -1.0, "-1.0" }, 287 { -1.0, "-1.0" },
288 { -0.8, "-0.8" }, 288 { -0.8, "-0.8" },
289 { -0.6, "-0.6" }, 289 { -0.6, "-0.6" },
290 { -0.4, "-0.4" }, 290 { -0.4, "-0.4" },
291 { -0.2, "-0.2" }, 291 { -0.2, "-0.2" },
294 { 0.4, "0.4" }, 294 { 0.4, "0.4" },
295 { 0.6, "0.6" }, 295 { 0.6, "0.6" },
296 { 0.8, "0.8" }, 296 { 0.8, "0.8" },
297 { 1.0, "1.0" } 297 { 1.0, "1.0" }
298 }; 298 };
299 compareTicks(ticks.ticks, expected); 299 compareTicks(ticks, expected);
300 } 300 }
301 301
302 void linear_221p23_623p7_57p4() 302 void linear_221p23_623p7_57p4()
303 { 303 {
304 auto ticks = ScaleTickIntervals::linear({ 221.23, 623.7, 4 }); 304 auto ticks = ScaleTickIntervals::linear({ 221.23, 623.7, 4 });
305 // only 4 ticks, not 5, because none of the rounded tick 305 // only 4 ticks, not 5, because none of the rounded tick
306 // values lies on an end value 306 // values lies on an end value
307 vector<ScaleTickIntervals::Tick> expected { 307 ScaleTickIntervals::Ticks expected {
308 { 230, "230" }, 308 { 230, "230" },
309 { 330, "330" }, 309 { 330, "330" },
310 { 430, "430" }, 310 { 430, "430" },
311 { 530, "530" }, 311 { 530, "530" },
312 }; 312 };
313 compareTicks(ticks.ticks, expected); 313 compareTicks(ticks, expected);
314 } 314 }
315 315
316 void linear_sqrt2_pi_7() 316 void linear_sqrt2_pi_7()
317 { 317 {
318 auto ticks = ScaleTickIntervals::linear({ sqrt(2.0), M_PI, 7 }); 318 auto ticks = ScaleTickIntervals::linear({ sqrt(2.0), M_PI, 7 });
319 // This would be better in steps of 0.25, but we only round to 319 // This would be better in steps of 0.25, but we only round to
320 // integral powers of ten 320 // integral powers of ten
321 vector<ScaleTickIntervals::Tick> expected { 321 ScaleTickIntervals::Ticks expected {
322 { 1.5, "1.5" }, 322 { 1.5, "1.5" },
323 { 1.7, "1.7" }, 323 { 1.7, "1.7" },
324 { 1.9, "1.9" }, 324 { 1.9, "1.9" },
325 { 2.1, "2.1" }, 325 { 2.1, "2.1" },
326 { 2.3, "2.3" }, 326 { 2.3, "2.3" },
327 { 2.5, "2.5" }, 327 { 2.5, "2.5" },
328 { 2.7, "2.7" }, 328 { 2.7, "2.7" },
329 { 2.9, "2.9" }, 329 { 2.9, "2.9" },
330 { 3.1, "3.1" }, 330 { 3.1, "3.1" },
331 }; 331 };
332 compareTicks(ticks.ticks, expected); 332 compareTicks(ticks, expected);
333 } 333 }
334 334
335 void linear_pi_avogadro_7() 335 void linear_pi_avogadro_7()
336 { 336 {
337 auto ticks = ScaleTickIntervals::linear({ M_PI, 6.022140857e23, 7 }); 337 auto ticks = ScaleTickIntervals::linear({ M_PI, 6.022140857e23, 7 });
338 vector<ScaleTickIntervals::Tick> expected { 338 ScaleTickIntervals::Ticks expected {
339 { 1e+21, "1.000e+21" }, 339 { 1e+21, "1.000e+21" },
340 { 8.7e+22, "8.700e+22" }, 340 { 8.7e+22, "8.700e+22" },
341 { 1.73e+23, "1.730e+23" }, 341 { 1.73e+23, "1.730e+23" },
342 { 2.59e+23, "2.590e+23" }, 342 { 2.59e+23, "2.590e+23" },
343 { 3.45e+23, "3.450e+23" }, 343 { 3.45e+23, "3.450e+23" },
344 { 4.31e+23, "4.310e+23" }, 344 { 4.31e+23, "4.310e+23" },
345 { 5.17e+23, "5.170e+23" }, 345 { 5.17e+23, "5.170e+23" },
346 }; 346 };
347 compareTicks(ticks.ticks, expected); 347 compareTicks(ticks, expected);
348 } 348 }
349 349
350 void linear_2_3_1() 350 void linear_2_3_1()
351 { 351 {
352 auto ticks = ScaleTickIntervals::linear({ 2, 3, 1 }); 352 auto ticks = ScaleTickIntervals::linear({ 2, 3, 1 });
353 vector<ScaleTickIntervals::Tick> expected { 353 ScaleTickIntervals::Ticks expected {
354 { 2.0, "2" }, 354 { 2.0, "2" },
355 { 3.0, "3" } 355 { 3.0, "3" }
356 }; 356 };
357 compareTicks(ticks.ticks, expected); 357 compareTicks(ticks, expected);
358 } 358 }
359 359
360 void linear_2_3_2() 360 void linear_2_3_2()
361 { 361 {
362 auto ticks = ScaleTickIntervals::linear({ 2, 3, 2 }); 362 auto ticks = ScaleTickIntervals::linear({ 2, 3, 2 });
363 vector<ScaleTickIntervals::Tick> expected { 363 ScaleTickIntervals::Ticks expected {
364 { 2.0, "2.0" }, 364 { 2.0, "2.0" },
365 { 2.5, "2.5" }, 365 { 2.5, "2.5" },
366 { 3.0, "3.0" } 366 { 3.0, "3.0" }
367 }; 367 };
368 compareTicks(ticks.ticks, expected); 368 compareTicks(ticks, expected);
369 } 369 }
370 370
371 void linear_2_3_3() 371 void linear_2_3_3()
372 { 372 {
373 auto ticks = ScaleTickIntervals::linear({ 2, 3, 3 }); 373 auto ticks = ScaleTickIntervals::linear({ 2, 3, 3 });
374 vector<ScaleTickIntervals::Tick> expected { 374 ScaleTickIntervals::Ticks expected {
375 { 2.0, "2.0" }, 375 { 2.0, "2.0" },
376 { 2.3, "2.3" }, 376 { 2.3, "2.3" },
377 { 2.6, "2.6" }, 377 { 2.6, "2.6" },
378 { 2.9, "2.9" } 378 { 2.9, "2.9" }
379 }; 379 };
380 compareTicks(ticks.ticks, expected); 380 compareTicks(ticks, expected);
381 } 381 }
382 382
383 void linear_2_3_4() 383 void linear_2_3_4()
384 { 384 {
385 auto ticks = ScaleTickIntervals::linear({ 2, 3, 4 }); 385 auto ticks = ScaleTickIntervals::linear({ 2, 3, 4 });
386 // This would be better in steps of 0.25, but we only round to 386 // This would be better in steps of 0.25, but we only round to
387 // integral powers of ten 387 // integral powers of ten
388 vector<ScaleTickIntervals::Tick> expected { 388 ScaleTickIntervals::Ticks expected {
389 { 2.0, "2.0" }, 389 { 2.0, "2.0" },
390 { 2.3, "2.3" }, 390 { 2.3, "2.3" },
391 { 2.6, "2.6" }, 391 { 2.6, "2.6" },
392 { 2.9, "2.9" } 392 { 2.9, "2.9" }
393 }; 393 };
394 compareTicks(ticks.ticks, expected); 394 compareTicks(ticks, expected);
395 } 395 }
396 396
397 void linear_2_3_5() 397 void linear_2_3_5()
398 { 398 {
399 auto ticks = ScaleTickIntervals::linear({ 2, 3, 5 }); 399 auto ticks = ScaleTickIntervals::linear({ 2, 3, 5 });
400 vector<ScaleTickIntervals::Tick> expected { 400 ScaleTickIntervals::Ticks expected {
401 { 2.0, "2.0" }, 401 { 2.0, "2.0" },
402 { 2.2, "2.2" }, 402 { 2.2, "2.2" },
403 { 2.4, "2.4" }, 403 { 2.4, "2.4" },
404 { 2.6, "2.6" }, 404 { 2.6, "2.6" },
405 { 2.8, "2.8" }, 405 { 2.8, "2.8" },
406 { 3.0, "3.0" } 406 { 3.0, "3.0" }
407 }; 407 };
408 compareTicks(ticks.ticks, expected); 408 compareTicks(ticks, expected);
409 } 409 }
410 410
411 void linear_2_3_6() 411 void linear_2_3_6()
412 { 412 {
413 auto ticks = ScaleTickIntervals::linear({ 2, 3, 6 }); 413 auto ticks = ScaleTickIntervals::linear({ 2, 3, 6 });
414 vector<ScaleTickIntervals::Tick> expected { 414 ScaleTickIntervals::Ticks expected {
415 { 2.0, "2.0" }, 415 { 2.0, "2.0" },
416 { 2.2, "2.2" }, 416 { 2.2, "2.2" },
417 { 2.4, "2.4" }, 417 { 2.4, "2.4" },
418 { 2.6, "2.6" }, 418 { 2.6, "2.6" },
419 { 2.8, "2.8" }, 419 { 2.8, "2.8" },
420 { 3.0, "3.0" } 420 { 3.0, "3.0" }
421 }; 421 };
422 compareTicks(ticks.ticks, expected); 422 compareTicks(ticks, expected);
423 } 423 }
424 424
425 void linear_1_1_10() 425 void linear_1_1_10()
426 { 426 {
427 // pathological range 427 // pathological range
428 auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 }); 428 auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 });
429 vector<ScaleTickIntervals::Tick> expected { 429 ScaleTickIntervals::Ticks expected {
430 { 1.0, "1.0" } 430 { 1.0, "1.0" }
431 }; 431 };
432 compareTicks(ticks.ticks, expected); 432 compareTicks(ticks, expected);
433 } 433 }
434 434
435 void linear_0_0_10() 435 void linear_0_0_10()
436 { 436 {
437 // pathological range 437 // pathological range
438 auto ticks = ScaleTickIntervals::linear({ 0, 0, 10 }); 438 auto ticks = ScaleTickIntervals::linear({ 0, 0, 10 });
439 vector<ScaleTickIntervals::Tick> expected { 439 ScaleTickIntervals::Ticks expected {
440 { 0.0, "0.0" } 440 { 0.0, "0.0" }
441 }; 441 };
442 compareTicks(ticks.ticks, expected); 442 compareTicks(ticks, expected);
443 } 443 }
444 444
445 void linear_0_1_1() 445 void linear_0_1_1()
446 { 446 {
447 auto ticks = ScaleTickIntervals::linear({ 0, 1, 1 }); 447 auto ticks = ScaleTickIntervals::linear({ 0, 1, 1 });
448 vector<ScaleTickIntervals::Tick> expected { 448 ScaleTickIntervals::Ticks expected {
449 { 0.0, "0" }, 449 { 0.0, "0" },
450 { 1.0, "1" } 450 { 1.0, "1" }
451 }; 451 };
452 compareTicks(ticks.ticks, expected); 452 compareTicks(ticks, expected);
453 } 453 }
454 454
455 void linear_0_1_0() 455 void linear_0_1_0()
456 { 456 {
457 // senseless input 457 // senseless input
458 auto ticks = ScaleTickIntervals::linear({ 0, 1, 0 }); 458 auto ticks = ScaleTickIntervals::linear({ 0, 1, 0 });
459 vector<ScaleTickIntervals::Tick> expected { 459 ScaleTickIntervals::Ticks expected {
460 }; 460 };
461 compareTicks(ticks.ticks, expected); 461 compareTicks(ticks, expected);
462 } 462 }
463 463
464 void linear_0_1_m1() 464 void linear_0_1_m1()
465 { 465 {
466 // senseless input 466 // senseless input
467 auto ticks = ScaleTickIntervals::linear({ 0, 1, -1 }); 467 auto ticks = ScaleTickIntervals::linear({ 0, 1, -1 });
468 vector<ScaleTickIntervals::Tick> expected { 468 ScaleTickIntervals::Ticks expected {
469 }; 469 };
470 compareTicks(ticks.ticks, expected); 470 compareTicks(ticks, expected);
471 } 471 }
472 472
473 void linear_0p465_778_10() 473 void linear_0p465_778_10()
474 { 474 {
475 // a case that gave unsatisfactory results in real life 475 // a case that gave unsatisfactory results in real life
476 auto ticks = ScaleTickIntervals::linear({ 0.465, 778.08, 10 }); 476 auto ticks = ScaleTickIntervals::linear({ 0.465, 778.08, 10 });
477 vector<ScaleTickIntervals::Tick> expected { 477 ScaleTickIntervals::Ticks expected {
478 }; 478 };
479 compareTicks(ticks.ticks, expected); 479 compareTicks(ticks, expected);
480 } 480 }
481 481
482 void log_1_10_2() 482 void log_1_10_2()
483 { 483 {
484 auto ticks = ScaleTickIntervals::logarithmic({ 1, 10, 2 }); 484 auto ticks = ScaleTickIntervals::logarithmic({ 1, 10, 2 });
485 vector<ScaleTickIntervals::Tick> expected { 485 ScaleTickIntervals::Ticks expected {
486 { 1.0, "1.0" }, 486 { 1.0, "1.0" },
487 { pow(10.0, 0.5), "3.2" }, 487 { pow(10.0, 0.5), "3.2" },
488 { 10.0, "10.0" }, 488 { 10.0, "10.0" },
489 }; 489 };
490 compareTicks(ticks.ticks, expected); 490 compareTicks(ticks, expected);
491 } 491 }
492 492
493 void log_0_10_2() 493 void log_0_10_2()
494 { 494 {
495 auto ticks = ScaleTickIntervals::logarithmic({ 0, 10, 2 }); 495 auto ticks = ScaleTickIntervals::logarithmic({ 0, 10, 2 });
496 vector<ScaleTickIntervals::Tick> expected { 496 ScaleTickIntervals::Ticks expected {
497 { 1e-10, "1e-10" }, 497 { 1e-10, "1e-10" },
498 { pow(10.0, -4.5), "3e-05" }, 498 { pow(10.0, -4.5), "3e-05" },
499 { 10.0, "1e+01" }, 499 { 10.0, "1e+01" },
500 }; 500 };
501 compareTicks(ticks.ticks, expected); 501 compareTicks(ticks, expected);
502 } 502 }
503 503
504 void log_pi_avogadro_7() 504 void log_pi_avogadro_7()
505 { 505 {
506 auto ticks = ScaleTickIntervals::logarithmic({ M_PI, 6.022140857e23, 7 }); 506 auto ticks = ScaleTickIntervals::logarithmic({ M_PI, 6.022140857e23, 7 });
507 vector<ScaleTickIntervals::Tick> expected { 507 ScaleTickIntervals::Ticks expected {
508 { 3.16228, "3e+00" }, 508 { 3.16228, "3e+00" },
509 { 6309.57, "6e+03" }, 509 { 6309.57, "6e+03" },
510 { 1.25893e+07, "1e+07" }, 510 { 1.25893e+07, "1e+07" },
511 { 2.51189e+10, "3e+10" }, 511 { 2.51189e+10, "3e+10" },
512 { 5.01187e+13, "5e+13" }, 512 { 5.01187e+13, "5e+13" },
513 { 1e+17, "1e+17" }, 513 { 1e+17, "1e+17" },
514 { 1.99526e+20, "2e+20" }, 514 { 1.99526e+20, "2e+20" },
515 { 3.98107e+23, "4e+23" }, 515 { 3.98107e+23, "4e+23" },
516 }; 516 };
517 compareTicks(ticks.ticks, expected, true); 517 compareTicks(ticks, expected, true);
518 } 518 }
519 }; 519 };
520 520
521 #endif 521 #endif
522 522