MCPcopy Create free account
hub / github.com/KDE/labplot / numeric

Method numeric

tests/backend/Axis/AxisTest3.cpp:303–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303void AxisTest3::numeric() {
304 QLocale::setDefault(QLocale::C); // use . as decimal separator
305 Project project;
306 auto* ws = new Worksheet(QStringLiteral("worksheet"));
307 QVERIFY(ws != nullptr);
308 project.addChild(ws);
309
310 Spreadsheet* spreadsheetData = new Spreadsheet(QStringLiteral("data"), false);
311 spreadsheetData->setColumnCount(2);
312 spreadsheetData->setRowCount(3);
313 project.addChild(spreadsheetData);
314
315 auto* xCol = spreadsheetData->column(0);
316 xCol->setColumnMode(AbstractColumn::ColumnMode::Double);
317 xCol->replaceValues(-1, QVector<double>({1., 2., 5.}));
318
319 auto* yCol = spreadsheetData->column(1);
320 yCol->replaceValues(-1, QVector<double>({2., 3., 4.}));
321
322 QCOMPARE(spreadsheetData->rowCount(), 3);
323 QCOMPARE(spreadsheetData->columnCount(), 2);
324
325 auto* p = new CartesianPlot(QStringLiteral("plot"));
326 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axes are created
327 p->setNiceExtend(false);
328 QVERIFY(p != nullptr);
329 ws->addChild(p);
330
331 auto* curve = new XYCurve(QStringLiteral("xy-curve"));
332 curve->setXColumn(xCol);
333 curve->setYColumn(yCol);
334 p->addChild(curve);
335
336 auto axes = p->children<Axis>();
337 QCOMPARE(axes.count(), 2);
338 QCOMPARE(axes.at(0)->name(), QStringLiteral("x"));
339 QCOMPARE(axes.at(1)->name(), QStringLiteral("y"));
340
341 auto* xAxis = static_cast<Axis*>(axes.at(0));
342 xAxis->setMajorTicksNumber(3, false);
343 QCOMPARE(xAxis->range().start(), 1.);
344 QCOMPARE(xAxis->range().end(), 5.);
345 QCOMPARE(xAxis->majorTicksType(), Axis::TicksType::TotalNumber);
346 QCOMPARE(xAxis->majorTicksNumber(), 3);
347 QCOMPARE(xAxis->labelsTextType(), Axis::LabelsTextType::PositionValues);
348
349 {
350 const auto v = xAxis->tickLabelStrings();
351 QStringList expectedStrings{
352 QStringLiteral("1"),
353 QStringLiteral("3"),
354 QStringLiteral("5"),
355 };
356 COMPARE_STRING_VECTORS(xAxis->tickLabelStrings(), expectedStrings);
357 }
358}
359
360void AxisTest3::numericSpacing() {

Callers

nothing calls this directly

Calls 15

setNiceExtendMethod · 0.80
setYColumnMethod · 0.80
setMajorTicksNumberMethod · 0.80
rangeMethod · 0.80
tickLabelStringsMethod · 0.80
addChildMethod · 0.45
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
columnMethod · 0.45
setColumnModeMethod · 0.45
replaceValuesMethod · 0.45
rowCountMethod · 0.45

Tested by

no test coverage detected