Mercurial > hg > svcore
comparison base/test/TestScaleTickIntervals.h @ 1412:b7a9edee85e0 scale-ticks
Change loop to something that feels more correct, though it makes no difference to the tests here. More tests, one failing.
author | Chris Cannam |
---|---|
date | Thu, 04 May 2017 08:32:41 +0100 |
parents | 1f0d071e7ce6 |
children | c6fa111b4553 |
comparison
equal
deleted
inserted
replaced
1411:1f0d071e7ce6 | 1412:b7a9edee85e0 |
---|---|
288 { 530, "530" }, | 288 { 530, "530" }, |
289 }; | 289 }; |
290 compareTicks(ticks.ticks, expected); | 290 compareTicks(ticks.ticks, expected); |
291 } | 291 } |
292 | 292 |
293 void linear_sqrt2_pi_7() | |
294 { | |
295 auto ticks = ScaleTickIntervals::linear({ sqrt(2.0), M_PI, 7 }); | |
296 // This would be better in steps of 0.25, but we only round to | |
297 // integral powers of ten | |
298 vector<ScaleTickIntervals::Tick> expected { | |
299 { 1.5, "1.5" }, | |
300 { 1.7, "1.7" }, | |
301 { 1.9, "1.9" }, | |
302 { 2.1, "2.1" }, | |
303 { 2.3, "2.3" }, | |
304 { 2.5, "2.5" }, | |
305 { 2.7, "2.7" }, | |
306 { 2.9, "2.9" }, | |
307 { 3.1, "3.1" }, | |
308 }; | |
309 compareTicks(ticks.ticks, expected); | |
310 } | |
311 | |
312 void linear_pi_avogadro_7() | |
313 { | |
314 auto ticks = ScaleTickIntervals::linear({ M_PI, 6.022140857e23, 7 }); | |
315 vector<ScaleTickIntervals::Tick> expected { | |
316 { 1e+21, "1.0e+21" }, | |
317 { 8.7e+22, "8.7e+22" }, | |
318 { 1.73e+23, "1.73e+23" }, | |
319 { 2.59e+23, "2.59e+23" }, | |
320 { 3.45e+23, "3.45e+23" }, | |
321 { 4.31e+23, "4.31e+23" }, | |
322 { 5.17e+23, "5.17e+23" }, | |
323 }; | |
324 compareTicks(ticks.ticks, expected); | |
325 } | |
326 | |
327 void linear_2_3_1() | |
328 { | |
329 auto ticks = ScaleTickIntervals::linear({ 2, 3, 1 }); | |
330 vector<ScaleTickIntervals::Tick> expected { | |
331 { 2.0, "2.0" }, | |
332 { 3.0, "3.0" } | |
333 }; | |
334 compareTicks(ticks.ticks, expected); | |
335 } | |
336 | |
337 void linear_2_3_2() | |
338 { | |
339 auto ticks = ScaleTickIntervals::linear({ 2, 3, 2 }); | |
340 vector<ScaleTickIntervals::Tick> expected { | |
341 { 2.0, "2.0" }, | |
342 { 2.5, "2.5" }, | |
343 { 3.0, "3.0" } | |
344 }; | |
345 compareTicks(ticks.ticks, expected); | |
346 } | |
347 | |
348 void linear_2_3_3() | |
349 { | |
350 auto ticks = ScaleTickIntervals::linear({ 2, 3, 3 }); | |
351 vector<ScaleTickIntervals::Tick> expected { | |
352 { 2.0, "2.0" }, | |
353 { 2.3, "2.3" }, | |
354 { 2.6, "2.6" }, | |
355 { 2.9, "2.9" } | |
356 }; | |
357 compareTicks(ticks.ticks, expected); | |
358 } | |
359 | |
360 void linear_2_3_4() | |
361 { | |
362 auto ticks = ScaleTickIntervals::linear({ 2, 3, 4 }); | |
363 // This would be better in steps of 0.25, but we only round to | |
364 // integral powers of ten | |
365 vector<ScaleTickIntervals::Tick> expected { | |
366 { 2.0, "2.0" }, | |
367 { 2.3, "2.3" }, | |
368 { 2.6, "2.6" }, | |
369 { 2.9, "2.9" } | |
370 }; | |
371 compareTicks(ticks.ticks, expected); | |
372 } | |
373 | |
374 void linear_2_3_5() | |
375 { | |
376 auto ticks = ScaleTickIntervals::linear({ 2, 3, 5 }); | |
377 vector<ScaleTickIntervals::Tick> expected { | |
378 { 2.0, "2.0" }, | |
379 { 2.2, "2.2" }, | |
380 { 2.4, "2.4" }, | |
381 { 2.6, "2.6" }, | |
382 { 2.8, "2.8" }, | |
383 { 3.0, "3.0" } | |
384 }; | |
385 compareTicks(ticks.ticks, expected); | |
386 } | |
387 | |
388 void linear_2_3_6() | |
389 { | |
390 auto ticks = ScaleTickIntervals::linear({ 2, 3, 6 }); | |
391 vector<ScaleTickIntervals::Tick> expected { | |
392 { 2.0, "2.0" }, | |
393 { 2.2, "2.2" }, | |
394 { 2.4, "2.4" }, | |
395 { 2.6, "2.6" }, | |
396 { 2.8, "2.8" }, | |
397 { 3.0, "3.0" } | |
398 }; | |
399 compareTicks(ticks.ticks, expected); | |
400 } | |
401 | |
293 void linear_1_1_10() | 402 void linear_1_1_10() |
294 { | 403 { |
295 auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 }); | 404 auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 }); |
296 vector<ScaleTickIntervals::Tick> expected { | 405 vector<ScaleTickIntervals::Tick> expected { |
297 { 1.0, "1.0" } | 406 { 1.0, "1.0" } |