annotate base/test/TestScaleTickIntervals.h @ 1440:04caefd35391 streaming-csv-writer

Add failing test for non zero selection start
author Lucas Thompson <dev@lucas.im>
date Tue, 17 Apr 2018 10:03:50 +0100
parents 8b7d6c1e1ab7
children 87ae75da6527
rev   line source
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@1417 49 void compareTicks(ScaleTickIntervals::Ticks ticks,
Chris@1417 50 ScaleTickIntervals::Ticks expected,
Chris@1415 51 bool fuzzier = false)
Chris@1407 52 {
Chris@1408 53 double eps = 1e-7;
Chris@1407 54 for (int i = 0; i < int(expected.size()); ++i) {
Chris@1407 55 if (i < int(ticks.size())) {
Chris@1415 56 bool pass = true;
Chris@1415 57 if (ticks[i].label != expected[i].label) {
Chris@1415 58 pass = false;
Chris@1415 59 } else if (!fuzzier) {
Chris@1415 60 if (fabs(ticks[i].value - expected[i].value) > eps) {
Chris@1415 61 pass = false;
Chris@1415 62 }
Chris@1415 63 } else {
Chris@1415 64 if (fabs(ticks[i].value - expected[i].value) >
Chris@1415 65 fabs(ticks[i].value) * 1e-5) {
Chris@1415 66 pass = false;
Chris@1415 67 }
Chris@1415 68 }
Chris@1415 69 if (!pass) {
Chris@1407 70 printDiff(ticks, expected);
Chris@1415 71 QCOMPARE(ticks[i].label, expected[i].label);
Chris@1415 72 QCOMPARE(ticks[i].value, expected[i].value);
Chris@1415 73 }
Chris@1407 74 }
Chris@1407 75 }
Chris@1408 76 if (ticks.size() != expected.size()) {
Chris@1408 77 printDiff(ticks, expected);
Chris@1408 78 }
Chris@1407 79 QCOMPARE(ticks.size(), expected.size());
Chris@1407 80 }
Chris@1407 81
Chris@1407 82 private slots:
Chris@1407 83 void linear_0_1_10()
Chris@1407 84 {
Chris@1407 85 auto ticks = ScaleTickIntervals::linear({ 0, 1, 10 });
Chris@1417 86 ScaleTickIntervals::Ticks expected {
Chris@1409 87 { 0.0, "0.0" },
Chris@1409 88 { 0.1, "0.1" },
Chris@1409 89 { 0.2, "0.2" },
Chris@1409 90 { 0.3, "0.3" },
Chris@1409 91 { 0.4, "0.4" },
Chris@1409 92 { 0.5, "0.5" },
Chris@1409 93 { 0.6, "0.6" },
Chris@1409 94 { 0.7, "0.7" },
Chris@1409 95 { 0.8, "0.8" },
Chris@1409 96 { 0.9, "0.9" },
Chris@1409 97 { 1.0, "1.0" }
Chris@1409 98 };
Chris@1417 99 compareTicks(ticks, expected);
Chris@1409 100 }
Chris@1409 101
Chris@1409 102 void linear_0_5_5()
Chris@1409 103 {
Chris@1409 104 auto ticks = ScaleTickIntervals::linear({ 0, 5, 5 });
Chris@1417 105 ScaleTickIntervals::Ticks expected {
Chris@1415 106 { 0, "0" },
Chris@1415 107 { 1, "1" },
Chris@1415 108 { 2, "2" },
Chris@1415 109 { 3, "3" },
Chris@1415 110 { 4, "4" },
Chris@1415 111 { 5, "5" },
Chris@1409 112 };
Chris@1417 113 compareTicks(ticks, expected);
Chris@1409 114 }
Chris@1409 115
Chris@1409 116 void linear_0_10_5()
Chris@1409 117 {
Chris@1409 118 auto ticks = ScaleTickIntervals::linear({ 0, 10, 5 });
Chris@1417 119 ScaleTickIntervals::Ticks expected {
Chris@1415 120 { 0, "0" },
Chris@1415 121 { 2, "2" },
Chris@1415 122 { 4, "4" },
Chris@1415 123 { 6, "6" },
Chris@1415 124 { 8, "8" },
Chris@1415 125 { 10, "10" }
Chris@1407 126 };
Chris@1417 127 compareTicks(ticks, expected);
Chris@1407 128 }
Chris@1407 129
Chris@1411 130 void linear_10_0_5()
Chris@1411 131 {
Chris@1411 132 auto ticks = ScaleTickIntervals::linear({ 10, 0, 5 });
Chris@1417 133 ScaleTickIntervals::Ticks expected {
Chris@1415 134 { 0, "0" },
Chris@1415 135 { 2, "2" },
Chris@1415 136 { 4, "4" },
Chris@1415 137 { 6, "6" },
Chris@1415 138 { 8, "8" },
Chris@1415 139 { 10, "10" }
Chris@1411 140 };
Chris@1417 141 compareTicks(ticks, expected);
Chris@1411 142 }
Chris@1411 143
Chris@1411 144 void linear_m10_0_5()
Chris@1411 145 {
Chris@1411 146 auto ticks = ScaleTickIntervals::linear({ -10, 0, 5 });
Chris@1417 147 ScaleTickIntervals::Ticks expected {
Chris@1415 148 { -10, "-10" },
Chris@1415 149 { -8, "-8" },
Chris@1415 150 { -6, "-6" },
Chris@1415 151 { -4, "-4" },
Chris@1415 152 { -2, "-2" },
Chris@1415 153 { 0, "0" }
Chris@1411 154 };
Chris@1417 155 compareTicks(ticks, expected);
Chris@1411 156 }
Chris@1411 157
Chris@1411 158 void linear_0_m10_5()
Chris@1411 159 {
Chris@1411 160 auto ticks = ScaleTickIntervals::linear({ 0, -10, 5 });
Chris@1417 161 ScaleTickIntervals::Ticks expected {
Chris@1415 162 { -10, "-10" },
Chris@1415 163 { -8, "-8" },
Chris@1415 164 { -6, "-6" },
Chris@1415 165 { -4, "-4" },
Chris@1415 166 { -2, "-2" },
Chris@1415 167 { 0, "0" }
Chris@1411 168 };
Chris@1417 169 compareTicks(ticks, expected);
Chris@1411 170 }
Chris@1411 171
Chris@1407 172 void linear_0_0p1_5()
Chris@1407 173 {
Chris@1407 174 auto ticks = ScaleTickIntervals::linear({ 0, 0.1, 5 });
Chris@1417 175 ScaleTickIntervals::Ticks expected {
Chris@1409 176 { 0.00, "0.00" },
Chris@1407 177 { 0.02, "0.02" },
Chris@1407 178 { 0.04, "0.04" },
Chris@1407 179 { 0.06, "0.06" },
Chris@1407 180 { 0.08, "0.08" },
Chris@1409 181 { 0.10, "0.10" }
Chris@1407 182 };
Chris@1417 183 compareTicks(ticks, expected);
Chris@1407 184 }
Chris@1407 185
Chris@1407 186 void linear_0_0p01_5()
Chris@1407 187 {
Chris@1407 188 auto ticks = ScaleTickIntervals::linear({ 0, 0.01, 5 });
Chris@1417 189 ScaleTickIntervals::Ticks expected {
Chris@1409 190 { 0.000, "0.000" },
Chris@1407 191 { 0.002, "0.002" },
Chris@1407 192 { 0.004, "0.004" },
Chris@1407 193 { 0.006, "0.006" },
Chris@1407 194 { 0.008, "0.008" },
Chris@1409 195 { 0.010, "0.010" }
Chris@1409 196 };
Chris@1417 197 compareTicks(ticks, expected);
Chris@1409 198 }
Chris@1409 199
Chris@1409 200 void linear_0_0p005_5()
Chris@1409 201 {
Chris@1409 202 auto ticks = ScaleTickIntervals::linear({ 0, 0.005, 5 });
Chris@1417 203 ScaleTickIntervals::Ticks expected {
Chris@1409 204 { 0.000, "0.000" },
Chris@1409 205 { 0.001, "0.001" },
Chris@1409 206 { 0.002, "0.002" },
Chris@1409 207 { 0.003, "0.003" },
Chris@1409 208 { 0.004, "0.004" },
Chris@1409 209 { 0.005, "0.005" }
Chris@1407 210 };
Chris@1417 211 compareTicks(ticks, expected);
Chris@1407 212 }
Chris@1407 213
Chris@1407 214 void linear_0_0p001_5()
Chris@1407 215 {
Chris@1407 216 auto ticks = ScaleTickIntervals::linear({ 0, 0.001, 5 });
Chris@1417 217 ScaleTickIntervals::Ticks expected {
Chris@1409 218 { 0.0000, "0.0e+00" },
Chris@1407 219 { 0.0002, "2.0e-04" },
Chris@1407 220 { 0.0004, "4.0e-04" },
Chris@1407 221 { 0.0006, "6.0e-04" },
Chris@1407 222 { 0.0008, "8.0e-04" },
Chris@1409 223 { 0.0010, "1.0e-03" }
Chris@1407 224 };
Chris@1417 225 compareTicks(ticks, expected);
Chris@1407 226 }
Chris@1407 227
Chris@1407 228 void linear_1_1p001_5()
Chris@1407 229 {
Chris@1407 230 auto ticks = ScaleTickIntervals::linear({ 1, 1.001, 5 });
Chris@1417 231 ScaleTickIntervals::Ticks expected {
Chris@1409 232 { 1.0000, "1.0000" },
Chris@1407 233 { 1.0002, "1.0002" },
Chris@1407 234 { 1.0004, "1.0004" },
Chris@1407 235 { 1.0006, "1.0006" },
Chris@1407 236 { 1.0008, "1.0008" },
Chris@1409 237 { 1.0010, "1.0010" }
Chris@1409 238 };
Chris@1417 239 compareTicks(ticks, expected);
Chris@1409 240 }
Chris@1409 241
Chris@1413 242 void linear_0p001_1_5()
Chris@1413 243 {
Chris@1413 244 auto ticks = ScaleTickIntervals::linear({ 0.001, 1, 5 });
Chris@1417 245 ScaleTickIntervals::Ticks expected {
Chris@1413 246 { 0.1, "0.1" },
Chris@1413 247 { 0.3, "0.3" },
Chris@1413 248 { 0.5, "0.5" },
Chris@1413 249 { 0.7, "0.7" },
Chris@1413 250 { 0.9, "0.9" },
Chris@1413 251 };
Chris@1417 252 compareTicks(ticks, expected);
Chris@1413 253 }
Chris@1413 254
Chris@1409 255 void linear_10000_10010_5()
Chris@1409 256 {
Chris@1409 257 auto ticks = ScaleTickIntervals::linear({ 10000, 10010, 5 });
Chris@1417 258 ScaleTickIntervals::Ticks expected {
Chris@1415 259 { 10000, "10000" },
Chris@1415 260 { 10002, "10002" },
Chris@1415 261 { 10004, "10004" },
Chris@1415 262 { 10006, "10006" },
Chris@1415 263 { 10008, "10008" },
Chris@1415 264 { 10010, "10010" },
Chris@1409 265 };
Chris@1417 266 compareTicks(ticks, expected);
Chris@1409 267 }
Chris@1409 268
Chris@1409 269 void linear_10000_20000_5()
Chris@1409 270 {
Chris@1409 271 auto ticks = ScaleTickIntervals::linear({ 10000, 20000, 5 });
Chris@1417 272 ScaleTickIntervals::Ticks expected {
Chris@1409 273 { 10000, "10000" },
Chris@1409 274 { 12000, "12000" },
Chris@1409 275 { 14000, "14000" },
Chris@1409 276 { 16000, "16000" },
Chris@1409 277 { 18000, "18000" },
Chris@1409 278 { 20000, "20000" },
Chris@1409 279 };
Chris@1417 280 compareTicks(ticks, expected);
Chris@1409 281 }
Chris@1409 282
Chris@1409 283 void linear_m1_1_10()
Chris@1409 284 {
Chris@1409 285 auto ticks = ScaleTickIntervals::linear({ -1, 1, 10 });
Chris@1417 286 ScaleTickIntervals::Ticks expected {
Chris@1409 287 { -1.0, "-1.0" },
Chris@1409 288 { -0.8, "-0.8" },
Chris@1409 289 { -0.6, "-0.6" },
Chris@1409 290 { -0.4, "-0.4" },
Chris@1409 291 { -0.2, "-0.2" },
Chris@1409 292 { 0.0, "0.0" },
Chris@1409 293 { 0.2, "0.2" },
Chris@1409 294 { 0.4, "0.4" },
Chris@1409 295 { 0.6, "0.6" },
Chris@1409 296 { 0.8, "0.8" },
Chris@1409 297 { 1.0, "1.0" }
Chris@1407 298 };
Chris@1417 299 compareTicks(ticks, expected);
Chris@1407 300 }
Chris@1411 301
Chris@1411 302 void linear_221p23_623p7_57p4()
Chris@1411 303 {
Chris@1411 304 auto ticks = ScaleTickIntervals::linear({ 221.23, 623.7, 4 });
Chris@1411 305 // only 4 ticks, not 5, because none of the rounded tick
Chris@1411 306 // values lies on an end value
Chris@1417 307 ScaleTickIntervals::Ticks expected {
Chris@1418 308 { 300, "300" },
Chris@1418 309 { 400, "400" },
Chris@1418 310 { 500, "500" },
Chris@1418 311 { 600, "600" },
Chris@1411 312 };
Chris@1417 313 compareTicks(ticks, expected);
Chris@1411 314 }
Chris@1411 315
Chris@1412 316 void linear_sqrt2_pi_7()
Chris@1412 317 {
Chris@1412 318 auto ticks = ScaleTickIntervals::linear({ sqrt(2.0), M_PI, 7 });
Chris@1412 319 // This would be better in steps of 0.25, but we only round to
Chris@1412 320 // integral powers of ten
Chris@1417 321 ScaleTickIntervals::Ticks expected {
Chris@1412 322 { 1.5, "1.5" },
Chris@1412 323 { 1.7, "1.7" },
Chris@1412 324 { 1.9, "1.9" },
Chris@1412 325 { 2.1, "2.1" },
Chris@1412 326 { 2.3, "2.3" },
Chris@1412 327 { 2.5, "2.5" },
Chris@1412 328 { 2.7, "2.7" },
Chris@1412 329 { 2.9, "2.9" },
Chris@1412 330 { 3.1, "3.1" },
Chris@1412 331 };
Chris@1417 332 compareTicks(ticks, expected);
Chris@1412 333 }
Chris@1412 334
Chris@1412 335 void linear_pi_avogadro_7()
Chris@1412 336 {
Chris@1412 337 auto ticks = ScaleTickIntervals::linear({ M_PI, 6.022140857e23, 7 });
Chris@1417 338 ScaleTickIntervals::Ticks expected {
Chris@1418 339 // not perfect, but ok-ish
Chris@1421 340 { 0, "0.0e+00" },
Chris@1421 341 { 9e+22, "9.0e+22" },
Chris@1421 342 { 1.8e+23, "1.8e+23" },
Chris@1421 343 { 2.7e+23, "2.7e+23" },
Chris@1421 344 { 3.6e+23, "3.6e+23" },
Chris@1421 345 { 4.5e+23, "4.5e+23" },
Chris@1421 346 { 5.4e+23, "5.4e+23" },
Chris@1412 347 };
Chris@1417 348 compareTicks(ticks, expected);
Chris@1412 349 }
Chris@1412 350
Chris@1412 351 void linear_2_3_1()
Chris@1412 352 {
Chris@1412 353 auto ticks = ScaleTickIntervals::linear({ 2, 3, 1 });
Chris@1417 354 ScaleTickIntervals::Ticks expected {
Chris@1415 355 { 2.0, "2" },
Chris@1415 356 { 3.0, "3" }
Chris@1412 357 };
Chris@1417 358 compareTicks(ticks, expected);
Chris@1412 359 }
Chris@1412 360
Chris@1412 361 void linear_2_3_2()
Chris@1412 362 {
Chris@1412 363 auto ticks = ScaleTickIntervals::linear({ 2, 3, 2 });
Chris@1417 364 ScaleTickIntervals::Ticks expected {
Chris@1412 365 { 2.0, "2.0" },
Chris@1412 366 { 2.5, "2.5" },
Chris@1412 367 { 3.0, "3.0" }
Chris@1412 368 };
Chris@1417 369 compareTicks(ticks, expected);
Chris@1412 370 }
Chris@1412 371
Chris@1412 372 void linear_2_3_3()
Chris@1412 373 {
Chris@1412 374 auto ticks = ScaleTickIntervals::linear({ 2, 3, 3 });
Chris@1417 375 ScaleTickIntervals::Ticks expected {
Chris@1412 376 { 2.0, "2.0" },
Chris@1412 377 { 2.3, "2.3" },
Chris@1412 378 { 2.6, "2.6" },
Chris@1412 379 { 2.9, "2.9" }
Chris@1412 380 };
Chris@1417 381 compareTicks(ticks, expected);
Chris@1412 382 }
Chris@1412 383
Chris@1412 384 void linear_2_3_4()
Chris@1412 385 {
Chris@1412 386 auto ticks = ScaleTickIntervals::linear({ 2, 3, 4 });
Chris@1412 387 // This would be better in steps of 0.25, but we only round to
Chris@1412 388 // integral powers of ten
Chris@1417 389 ScaleTickIntervals::Ticks expected {
Chris@1412 390 { 2.0, "2.0" },
Chris@1412 391 { 2.3, "2.3" },
Chris@1412 392 { 2.6, "2.6" },
Chris@1412 393 { 2.9, "2.9" }
Chris@1412 394 };
Chris@1417 395 compareTicks(ticks, expected);
Chris@1412 396 }
Chris@1412 397
Chris@1412 398 void linear_2_3_5()
Chris@1412 399 {
Chris@1412 400 auto ticks = ScaleTickIntervals::linear({ 2, 3, 5 });
Chris@1417 401 ScaleTickIntervals::Ticks expected {
Chris@1412 402 { 2.0, "2.0" },
Chris@1412 403 { 2.2, "2.2" },
Chris@1412 404 { 2.4, "2.4" },
Chris@1412 405 { 2.6, "2.6" },
Chris@1412 406 { 2.8, "2.8" },
Chris@1412 407 { 3.0, "3.0" }
Chris@1412 408 };
Chris@1417 409 compareTicks(ticks, expected);
Chris@1412 410 }
Chris@1412 411
Chris@1412 412 void linear_2_3_6()
Chris@1412 413 {
Chris@1412 414 auto ticks = ScaleTickIntervals::linear({ 2, 3, 6 });
Chris@1417 415 ScaleTickIntervals::Ticks expected {
Chris@1412 416 { 2.0, "2.0" },
Chris@1412 417 { 2.2, "2.2" },
Chris@1412 418 { 2.4, "2.4" },
Chris@1412 419 { 2.6, "2.6" },
Chris@1412 420 { 2.8, "2.8" },
Chris@1412 421 { 3.0, "3.0" }
Chris@1412 422 };
Chris@1417 423 compareTicks(ticks, expected);
Chris@1412 424 }
Chris@1412 425
Chris@1411 426 void linear_1_1_10()
Chris@1411 427 {
Chris@1415 428 // pathological range
Chris@1411 429 auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 });
Chris@1417 430 ScaleTickIntervals::Ticks expected {
Chris@1418 431 { 1.0, "1" }
Chris@1411 432 };
Chris@1417 433 compareTicks(ticks, expected);
Chris@1411 434 }
Chris@1411 435
Chris@1411 436 void linear_0_0_10()
Chris@1411 437 {
Chris@1415 438 // pathological range
Chris@1411 439 auto ticks = ScaleTickIntervals::linear({ 0, 0, 10 });
Chris@1417 440 ScaleTickIntervals::Ticks expected {
Chris@1418 441 { 0.0, "0" }
Chris@1411 442 };
Chris@1417 443 compareTicks(ticks, expected);
Chris@1411 444 }
Chris@1411 445
Chris@1411 446 void linear_0_1_1()
Chris@1411 447 {
Chris@1411 448 auto ticks = ScaleTickIntervals::linear({ 0, 1, 1 });
Chris@1417 449 ScaleTickIntervals::Ticks expected {
Chris@1415 450 { 0.0, "0" },
Chris@1415 451 { 1.0, "1" }
Chris@1411 452 };
Chris@1417 453 compareTicks(ticks, expected);
Chris@1411 454 }
Chris@1411 455
Chris@1411 456 void linear_0_1_0()
Chris@1411 457 {
Chris@1416 458 // senseless input
Chris@1411 459 auto ticks = ScaleTickIntervals::linear({ 0, 1, 0 });
Chris@1417 460 ScaleTickIntervals::Ticks expected {
Chris@1418 461 { 0.0, "0" },
Chris@1411 462 };
Chris@1417 463 compareTicks(ticks, expected);
Chris@1411 464 }
Chris@1411 465
Chris@1411 466 void linear_0_1_m1()
Chris@1411 467 {
Chris@1416 468 // senseless input
Chris@1411 469 auto ticks = ScaleTickIntervals::linear({ 0, 1, -1 });
Chris@1417 470 ScaleTickIntervals::Ticks expected {
Chris@1418 471 { 0.0, "0" },
Chris@1411 472 };
Chris@1417 473 compareTicks(ticks, expected);
Chris@1411 474 }
Chris@1414 475
Chris@1416 476 void linear_0p465_778_10()
Chris@1416 477 {
Chris@1416 478 // a case that gave unsatisfactory results in real life
Chris@1418 479 // (initially it had the first tick at 1)
Chris@1416 480 auto ticks = ScaleTickIntervals::linear({ 0.465, 778.08, 10 });
Chris@1417 481 ScaleTickIntervals::Ticks expected {
Chris@1418 482 { 10, "10" },
Chris@1418 483 { 90, "90" },
Chris@1418 484 { 170, "170" },
Chris@1418 485 { 250, "250" },
Chris@1418 486 { 330, "330" },
Chris@1418 487 { 410, "410" },
Chris@1418 488 { 490, "490" },
Chris@1418 489 { 570, "570" },
Chris@1418 490 { 650, "650" },
Chris@1418 491 { 730, "730" },
Chris@1416 492 };
Chris@1417 493 compareTicks(ticks, expected);
Chris@1416 494 }
Chris@1416 495
Chris@1414 496 void log_1_10_2()
Chris@1414 497 {
Chris@1414 498 auto ticks = ScaleTickIntervals::logarithmic({ 1, 10, 2 });
Chris@1417 499 ScaleTickIntervals::Ticks expected {
Chris@1414 500 { 1.0, "1.0" },
Chris@1414 501 { pow(10.0, 0.5), "3.2" },
Chris@1414 502 { 10.0, "10.0" },
Chris@1414 503 };
Chris@1417 504 compareTicks(ticks, expected);
Chris@1414 505 }
Chris@1414 506
Chris@1414 507 void log_0_10_2()
Chris@1414 508 {
Chris@1414 509 auto ticks = ScaleTickIntervals::logarithmic({ 0, 10, 2 });
Chris@1417 510 ScaleTickIntervals::Ticks expected {
Chris@1418 511 { 1e-6, "1e-06" },
Chris@1418 512 { 1, "1" },
Chris@1414 513 };
Chris@1417 514 compareTicks(ticks, expected);
Chris@1414 515 }
Chris@1415 516
Chris@1415 517 void log_pi_avogadro_7()
Chris@1415 518 {
Chris@1415 519 auto ticks = ScaleTickIntervals::logarithmic({ M_PI, 6.022140857e23, 7 });
Chris@1417 520 ScaleTickIntervals::Ticks expected {
Chris@1418 521 { 1000, "1e+03" },
Chris@1418 522 { 1e+06, "1e+06" },
Chris@1418 523 { 1e+09, "1e+09" },
Chris@1418 524 { 1e+12, "1e+12" },
Chris@1418 525 { 1e+15, "1e+15" },
Chris@1418 526 { 1e+18, "1e+18" },
Chris@1418 527 { 1e+21, "1e+21" },
Chris@1415 528 };
Chris@1417 529 compareTicks(ticks, expected, true);
Chris@1415 530 }
Chris@1418 531
Chris@1418 532 void log_0p465_778_10()
Chris@1418 533 {
Chris@1418 534 auto ticks = ScaleTickIntervals::logarithmic({ 0.465, 778.08, 10 });
Chris@1418 535 ScaleTickIntervals::Ticks expected {
Chris@1418 536 { 0.5, "0.5" },
Chris@1418 537 { 1, "1.0" },
Chris@1418 538 { 2, "2.0" },
Chris@1418 539 { 4, "4.0" },
Chris@1418 540 { 8, "8.0" },
Chris@1418 541 { 16, "16.0" },
Chris@1418 542 { 32, "32.0" },
Chris@1418 543 { 64, "64.0" },
Chris@1418 544 { 128, "128.0" },
Chris@1418 545 { 256, "256.0" },
Chris@1418 546 { 512, "512.0" },
Chris@1418 547 };
Chris@1418 548 compareTicks(ticks, expected);
Chris@1418 549 }
Chris@1418 550
Chris@1407 551 };
Chris@1407 552
Chris@1407 553 #endif
Chris@1407 554
Chris@1407 555