Skip to content

Commit

Permalink
Improve testing code by multiple small changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Jan 10, 2025
1 parent 706ce1b commit c17bf74
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
11 changes: 7 additions & 4 deletions tests/GroupPlotTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ void preparePlot(GroupPlot& plot)
quantilesVector.push_back(quantiles);
}

plot.setAxisScale(QwtPlot::yLeft, 0, 8);
plot.setAxisScale(QwtPlot::yRight, 0, 8);
plot.setAxisScale(QwtPlot::xBottom, 0.5, common::getValues().size() + 0.5,
1);
const double maxValueForXAxis{8};
plot.setAxisScale(QwtPlot::yLeft, 0, maxValueForXAxis);
plot.setAxisScale(QwtPlot::yRight, 0, maxValueForXAxis);

const double maxValueForBottomAxis{
static_cast<double>(common::getValues().size()) + 0.5};
plot.setAxisScale(QwtPlot::xBottom, 0.5, maxValueForBottomAxis, 1);
plot.setNewData(std::move(quantilesVector), common::getNames());
plot.resize(common::getPlotSize());
}
Expand Down
12 changes: 6 additions & 6 deletions tests/QuantilesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

#include <qwtble/Quantiles.h>

void QuantilesTest::testToolTip()
void QuantilesTest::testToolTip() const
{
Quantiles quantiles;
quantiles.init(values_);
const QString expected(QStringLiteral(
const QString expected{QStringLiteral(
"<table>"
"<tr><td>Data count:</td><td ALIGN=RIGHT>11</td></tr>\n"
"<tr><td>Average</td><td ALIGN=RIGHT>66.62</td></tr>\n"
Expand All @@ -21,22 +21,22 @@ void QuantilesTest::testToolTip()
"<tr><td>Q10</td><td ALIGN=RIGHT>7.02</td></tr>\n"
"<tr><td>Minimum</td><td ALIGN=RIGHT>5.00</td></tr>\n"
"<tr><td>Std. deviation</td><td ALIGN=RIGHT>54.48</td></tr>\n"
"</table>"));
"</table>")};
QCOMPARE(quantiles.getValuesAsToolTip(), expected);
}

void QuantilesTest::testToolTipForOneValue()
void QuantilesTest::testToolTipForOneValue() const
{
Quantiles quantiles;
const QVector<double> singleItemData{3};
quantiles.init(singleItemData);
const QString expected(
const QString expected{
QStringLiteral("<table>"
"<tr><td>Data count:</td><td ALIGN=RIGHT>1</td></tr>\n"
"<tr><td>Average</td><td ALIGN=RIGHT>3.00</td></tr>\n"
"<tr><td>Maximum</td><td ALIGN=RIGHT>3.00</td></tr>\n"
"<tr><td>Minimum</td><td ALIGN=RIGHT>3.00</td></tr>\n"
"</table>"));
"</table>")};
QCOMPARE(quantiles.getValuesAsToolTip(), expected);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/QuantilesTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class QuantilesTest : public QObject
QVector<double> values_{84.66, 40., 5., 7.02, 177.01, 110.23,
138.12, 54.94, 20., 80., 15.85};
private Q_SLOTS:
void testToolTip();
void testToolTip() const;

void testToolTipForOneValue();
void testToolTipForOneValue() const;

void testComputing();

Expand Down

0 comments on commit c17bf74

Please sign in to comment.