1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
/*
SPDX-FileCopyrightText: 2012 Benjamin Port <benjamin.port@ben2367.fr>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <kplotpoint.h>
#include <QTest>
class KPlotPointTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testConstructor()
{
KPlotPoint *p1 = new KPlotPoint(2.0, 3.0, QStringLiteral("label"), 5.0);
KPlotPoint *p2 = new KPlotPoint(QPointF(2.0, 3.0), QStringLiteral("label"), 5.0);
QCOMPARE(p1->x(), 2.0);
QCOMPARE(p2->x(), 2.0);
QCOMPARE(p1->y(), 3.0);
QCOMPARE(p2->y(), 3.0);
QCOMPARE(p1->barWidth(), 5.0);
QCOMPARE(p2->barWidth(), 5.0);
QCOMPARE(p1->label(), QString::fromLatin1("label"));
QCOMPARE(p2->label(), QString::fromLatin1("label"));
delete p1;
delete p2;
}
void testPosition()
{
KPlotPoint *p1 = new KPlotPoint(2.0, 3.0, QStringLiteral("label"), 5.0);
p1->setX(4.0);
QCOMPARE(p1->x(), 4.0);
p1->setY(6.0);
QCOMPARE(p1->y(), 6.0);
QCOMPARE(p1->position(), QPointF(4.0, 6.0));
p1->setPosition(QPointF(1.0, 7.0));
QCOMPARE(p1->position(), QPointF(1.0, 7.0));
QCOMPARE(p1->x(), 1.0);
QCOMPARE(p1->y(), 7.0);
delete p1;
}
void testLabel()
{
KPlotPoint *p1 = new KPlotPoint(2.0, 3.0, QStringLiteral("label"), 5.0);
p1->setLabel(QStringLiteral("newLabel"));
QCOMPARE(p1->label(), QString::fromLatin1("newLabel"));
delete p1;
}
void testBarWidth()
{
KPlotPoint *p1 = new KPlotPoint(2.0, 3.0, QStringLiteral("label"), 5.0);
p1->setBarWidth(5.0);
QCOMPARE(p1->barWidth(), 5.0);
delete p1;
}
};
QTEST_MAIN(KPlotPointTest)
#include "kplotpointtest.moc"
|