Mercurial > hg > svcore
comparison base/test/TestScaleTickIntervals.h @ 1461:45519a9836e6
Merge from branch horizontal-scale
author | Chris Cannam |
---|---|
date | Thu, 03 May 2018 15:24:06 +0100 |
parents | 9528c73aa98c |
children | 2b2b58ae8b59 |
comparison
equal
deleted
inserted
replaced
1458:0fb5d4e6edeb | 1461:45519a9836e6 |
---|---|
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() |
496 void log_1_10_2() | 496 void log_1_10_2() |
497 { | 497 { |
498 auto ticks = ScaleTickIntervals::logarithmic({ 1, 10, 2 }); | 498 auto ticks = ScaleTickIntervals::logarithmic({ 1, 10, 2 }); |
499 ScaleTickIntervals::Ticks expected { | 499 ScaleTickIntervals::Ticks expected { |
500 { 1.0, "1.0" }, | 500 { 1.0, "1.0" }, |
501 { pow(10.0, 0.5), "3.2" }, | 501 { 3.2, "3.2" }, |
502 { 10.0, "10.0" }, | 502 { 10.0, "10" }, |
503 }; | 503 }; |
504 compareTicks(ticks, expected); | 504 compareTicks(ticks, expected); |
505 } | 505 } |
506 | 506 |
507 void log_0_10_2() | 507 void log_0_10_2() |
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" }, |
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.50" }, |
537 { 1, "1.0" }, | 537 { 1, "1.0" }, |
538 { 2, "2.0" }, | 538 { 2, "2.0" }, |
539 { 4, "4.0" }, | 539 { 4, "4.0" }, |
540 { 8, "8.0" }, | 540 { 8, "8.0" }, |
541 { 16, "16.0" }, | 541 { 16, "16" }, |
542 { 32, "32.0" }, | 542 { 32, "32" }, |
543 { 64, "64.0" }, | 543 { 64, "64" }, |
544 { 128, "128.0" }, | 544 { 130, "130" }, |
545 { 256, "256.0" }, | 545 { 260, "260" }, |
546 { 512, "512.0" }, | 546 { 510, "510" }, |
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.3, "6.3" }, | |
558 { 16.0, "16" }, | |
559 { 40.0, "40" }, | |
560 { 100.0, "100" }, | |
561 { 250.0, "250" }, | |
562 { 630.0, "630" }, | |
563 { 1600.0, "1600" }, | |
564 { 4000.0, "4000" }, | |
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 { 250, "250" }, | |
591 { 630, "630" }, | |
592 { 1600, "1600" }, | |
593 { 4000, "4000" }, | |
594 { 10000, "1e+04" }, | |
595 { 25000, "2.5e+04" }, | |
596 { 63000, "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 |