| 488 | } |
| 489 | |
| 490 | void AxisTest3::numericSpacingStartValueNonZero() { |
| 491 | QLocale::setDefault(QLocale::C); // use . as decimal separator |
| 492 | Project project; |
| 493 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 494 | QVERIFY(ws != nullptr); |
| 495 | project.addChild(ws); |
| 496 | |
| 497 | Spreadsheet* spreadsheetData = new Spreadsheet(QStringLiteral("data"), false); |
| 498 | spreadsheetData->setColumnCount(2); |
| 499 | spreadsheetData->setRowCount(3); |
| 500 | project.addChild(spreadsheetData); |
| 501 | |
| 502 | auto* xCol = spreadsheetData->column(0); |
| 503 | xCol->setColumnMode(AbstractColumn::ColumnMode::Double); |
| 504 | xCol->replaceValues(-1, QVector<double>({1., 2., 5.})); |
| 505 | |
| 506 | auto* yCol = spreadsheetData->column(1); |
| 507 | yCol->replaceValues(-1, QVector<double>({2., 3., 4.})); |
| 508 | |
| 509 | QCOMPARE(spreadsheetData->rowCount(), 3); |
| 510 | QCOMPARE(spreadsheetData->columnCount(), 2); |
| 511 | |
| 512 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 513 | p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axes are created |
| 514 | p->setNiceExtend(false); |
| 515 | QVERIFY(p != nullptr); |
| 516 | ws->addChild(p); |
| 517 | |
| 518 | auto* curve = new XYCurve(QStringLiteral("xy-curve")); |
| 519 | curve->setXColumn(xCol); |
| 520 | curve->setYColumn(yCol); |
| 521 | p->addChild(curve); |
| 522 | |
| 523 | auto axes = p->children<Axis>(); |
| 524 | QCOMPARE(axes.count(), 2); |
| 525 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 526 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 527 | |
| 528 | auto* xAxis = static_cast<Axis*>(axes.at(0)); |
| 529 | xAxis->setMajorTicksSpacing(0.7); |
| 530 | QCOMPARE(xAxis->range().start(), 1.); |
| 531 | QCOMPARE(xAxis->range().end(), 5.); |
| 532 | xAxis->setMajorTicksType(Axis::TicksType::Spacing); |
| 533 | // QCOMPARE(xAxis->majorTicksNumber(), 3); |
| 534 | QCOMPARE(xAxis->labelsTextType(), Axis::LabelsTextType::PositionValues); |
| 535 | xAxis->setMajorTicksStartType(Axis::TicksStartType::Absolute); |
| 536 | xAxis->setMajorTickStartValue(1.7); |
| 537 | QVERIFY(xAxis->majorTickStartValue() > 0); |
| 538 | { |
| 539 | QStringList expectedStrings{ |
| 540 | QStringLiteral("1.7"), |
| 541 | QStringLiteral("2.4"), |
| 542 | QStringLiteral("3.1"), |
| 543 | QStringLiteral("3.8"), |
| 544 | QStringLiteral("4.5"), |
| 545 | }; |
| 546 | COMPARE_STRING_VECTORS(xAxis->tickLabelStrings(), expectedStrings); |
| 547 | } |
nothing calls this directly
no test coverage detected