Test: Begin QuantitySpinBox QTests
This commit is contained in:
committed by
Chris Hennes
parent
8a4e8ca60e
commit
ee7779455a
62
tests/src/Gui/QuantitySpinBox.cpp
Normal file
62
tests/src/Gui/QuantitySpinBox.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTest>
|
||||
|
||||
#include <App/Application.h>
|
||||
|
||||
#include "Gui/QuantitySpinBox.h"
|
||||
|
||||
// NOLINTBEGIN(readability-magic-numbers)
|
||||
|
||||
class testQuantitySpinBox: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
testQuantitySpinBox()
|
||||
{
|
||||
if (App::Application::GetARGC() == 0) {
|
||||
constexpr int argc = 1;
|
||||
std::array<char*, argc> argv {"FreeCAD"};
|
||||
App::Application::Config()["ExeName"] = "FreeCAD";
|
||||
App::Application::init(argc, argv.data());
|
||||
}
|
||||
qsb = std::make_unique<Gui::QuantitySpinBox>();
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void init()
|
||||
{}
|
||||
|
||||
void cleanup()
|
||||
{}
|
||||
|
||||
void test_SimpleBaseUnit()// NOLINT
|
||||
{
|
||||
auto result = qsb->valueFromText("1mm");
|
||||
QCOMPARE(result, Base::Quantity(1, QLatin1String("mm")));
|
||||
}
|
||||
|
||||
void test_UnitInNumerator()// NOLINT
|
||||
{
|
||||
auto result = qsb->valueFromText("1mm/10");
|
||||
QCOMPARE(result, Base::Quantity(0.1, QLatin1String("mm")));
|
||||
}
|
||||
|
||||
void test_UnitInDenominator()// NOLINT
|
||||
{
|
||||
auto result = qsb->valueFromText("1/10mm");
|
||||
QCOMPARE(result, Base::Quantity(0.1, QLatin1String("mm")));
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<Gui::QuantitySpinBox> qsb;
|
||||
};
|
||||
|
||||
// NOLINTEND(readability-magic-numbers)
|
||||
|
||||
QTEST_MAIN(testQuantitySpinBox)
|
||||
|
||||
#include "QuantitySpinBox.moc"
|
||||
Reference in New Issue
Block a user