comparison base/test/TestScaleTickIntervals.h @ 1459:3a128665fa6f horizontal-scale

Fixes to logarithmic scale tick intervals. The approach here is not right, though -- and I've left in a failing test or two to remind me of that
author Chris Cannam
date Wed, 02 May 2018 14:17:10 +0100
parents 48e9f538e6e9
children 9528c73aa98c
comparison
equal deleted inserted replaced
1458:0fb5d4e6edeb 1459:3a128665fa6f
426 void linear_1_1_10() 426 void linear_1_1_10()
427 { 427 {
428 // pathological range 428 // pathological range
429 auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 }); 429 auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 });
430 ScaleTickIntervals::Ticks expected { 430 ScaleTickIntervals::Ticks expected {
431 { 1.0, "1" } 431 { 1.0, "1.0" }
432 }; 432 };
433 compareTicks(ticks, expected); 433 compareTicks(ticks, expected);
434 } 434 }
435 435
436 void linear_0_0_10() 436 void linear_0_0_10()
437 { 437 {
438 // pathological range 438 // pathological range
439 auto ticks = ScaleTickIntervals::linear({ 0, 0, 10 }); 439 auto ticks = ScaleTickIntervals::linear({ 0, 0, 10 });
440 ScaleTickIntervals::Ticks expected { 440 ScaleTickIntervals::Ticks expected {
441 { 0.0, "0" } 441 { 0.0, "0.0" }
442 }; 442 };
443 compareTicks(ticks, expected); 443 compareTicks(ticks, expected);
444 } 444 }
445 445
446 void linear_0_1_1() 446 void linear_0_1_1()
456 void linear_0_1_0() 456 void linear_0_1_0()
457 { 457 {
458 // senseless input 458 // senseless input
459 auto ticks = ScaleTickIntervals::linear({ 0, 1, 0 }); 459 auto ticks = ScaleTickIntervals::linear({ 0, 1, 0 });
460 ScaleTickIntervals::Ticks expected { 460 ScaleTickIntervals::Ticks expected {
461 { 0.0, "0" }, 461 { 0.0, "0.0" },
462 }; 462 };
463 compareTicks(ticks, expected); 463 compareTicks(ticks, expected);
464 } 464 }
465 465
466 void linear_0_1_m1() 466 void linear_0_1_m1()
467 { 467 {
468 // senseless input 468 // senseless input
469 auto ticks = ScaleTickIntervals::linear({ 0, 1, -1 }); 469 auto ticks = ScaleTickIntervals::linear({ 0, 1, -1 });
470 ScaleTickIntervals::Ticks expected { 470 ScaleTickIntervals::Ticks expected {
471 { 0.0, "0" }, 471 { 0.0, "0.0" },
472 }; 472 };
473 compareTicks(ticks, expected); 473 compareTicks(ticks, expected);
474 } 474 }
475 475
476 void linear_0p465_778_10() 476 void linear_0p465_778_10()
516 516
517 void log_pi_avogadro_7() 517 void log_pi_avogadro_7()
518 { 518 {
519 auto ticks = ScaleTickIntervals::logarithmic({ M_PI, 6.022140857e23, 7 }); 519 auto ticks = ScaleTickIntervals::logarithmic({ M_PI, 6.022140857e23, 7 });
520 ScaleTickIntervals::Ticks expected { 520 ScaleTickIntervals::Ticks expected {
521 { 1000, "1e+03" }, 521 { 1000, "1000.0" },
522 { 1e+06, "1e+06" }, 522 { 1e+06, "1e+06" },
523 { 1e+09, "1e+09" }, 523 { 1e+09, "1e+09" },
524 { 1e+12, "1e+12" }, 524 { 1e+12, "1e+12" },
525 { 1e+15, "1e+15" }, 525 { 1e+15, "1e+15" },
526 { 1e+18, "1e+18" }, 526 { 1e+18, "1e+18" },
527 { 1e+21, "1e+21" }, 527 { 1e+21, "1e+21" },
528 }; 528 };
529 compareTicks(ticks, expected, true); 529 compareTicks(ticks, expected, true);
530 } 530 }
531 531
532 void log_0p465_778_10() 532 void log_0p465_778_10()
533 { 533 {
534 auto ticks = ScaleTickIntervals::logarithmic({ 0.465, 778.08, 10 }); 534 auto ticks = ScaleTickIntervals::logarithmic({ 0.465, 778.08, 10 });
535 ScaleTickIntervals::Ticks expected { 535 ScaleTickIntervals::Ticks expected {
536 { 0.5, "0.5" }, 536 { 0.5, "0.5" },
546 { 512, "512.0" }, 546 { 512, "512.0" },
547 }; 547 };
548 compareTicks(ticks, expected); 548 compareTicks(ticks, expected);
549 } 549 }
550 550
551 void log_1_10k_10()
552 {
553 auto ticks = ScaleTickIntervals::logarithmic({ 1.0, 10000.0, 10 });
554 ScaleTickIntervals::Ticks expected {
555 { 1.0, "1.0" },
556 { 2.5, "2.5" },
557 { 6.0, "6.0" },
558 { 16.0, "16.0" },
559 { 40.0, "40.0" },
560 { 100.0, "100.0" },
561 { 250.0, "250.0" },
562 { 600.0, "600.0" },
563 { 1600.0, "1600.0" },
564 { 4000.0, "4000.0" },
565 { 10000.0, "1e+04" },
566 };
567 compareTicks(ticks, expected, true);
568 }
569
570 void log_80_10k_6()
571 {
572 auto ticks = ScaleTickIntervals::logarithmic({ 80.0, 10000.0, 6 });
573 ScaleTickIntervals::Ticks expected {
574 { 130, "130" },
575 { 260, "260" },
576 { 510, "510" },
577 { 1000, "1000" },
578 { 2000, "2000" },
579 { 4100, "4100" },
580 { 8200, "8200" }
581 };
582 compareTicks(ticks, expected, true);
583 }
584
585 void log_80_800k_10()
586 {
587 auto ticks = ScaleTickIntervals::logarithmic({ 80.0, 800000.0, 10 });
588 ScaleTickIntervals::Ticks expected {
589 { 100, "100" },
590 { 251, "251" },
591 { 631, "631" },
592 { 1580, "1580" },
593 { 3980, "3980" },
594 { 10000, "10000" },
595 { 25100, "2.5e+04" },
596 { 63100, "6.3e+04" },
597 { 160000, "1.6e+05" },
598 { 400000, "4e+05" },
599 };
600 compareTicks(ticks, expected, true);
601 }
602
603 void log_0_1_0()
604 {
605 // senseless input
606 auto ticks = ScaleTickIntervals::logarithmic({ 0, 1, 0 });
607 ScaleTickIntervals::Ticks expected {
608 };
609 compareTicks(ticks, expected);
610 }
611
612 void log_0_1_m1()
613 {
614 // senseless input
615 auto ticks = ScaleTickIntervals::logarithmic({ 0, 1, -1 });
616 ScaleTickIntervals::Ticks expected {
617 };
618 compareTicks(ticks, expected);
619 }
620
551 }; 621 };
552 622
553 #endif 623 #endif
554 624
555 625