| | |
| |
|
| | #include <QDebug> |
| | #include <QTest> |
| |
|
| | #include <App/Application.h> |
| |
|
| | #include "Gui/QuantitySpinBox.h" |
| | #include <src/App/InitApplication.h> |
| |
|
| | |
| |
|
| | class testQuantitySpinBox: public QObject |
| | { |
| | Q_OBJECT |
| |
|
| | public: |
| | testQuantitySpinBox() |
| | { |
| | tests::initApplication(); |
| | qsb = std::make_unique<Gui::QuantitySpinBox>(); |
| | } |
| |
|
| | private Q_SLOTS: |
| |
|
| | void init() |
| | {} |
| |
|
| | void cleanup() |
| | {} |
| |
|
| | void test_SimpleBaseUnit() |
| | { |
| | auto result = qsb->valueFromText("1mm"); |
| | QCOMPARE(result, Base::Quantity(1, "mm")); |
| | } |
| |
|
| | void test_UnitInNumerator() |
| | { |
| | auto result = qsb->valueFromText("1mm/10"); |
| | QCOMPARE(result, Base::Quantity(0.1, "mm")); |
| | } |
| |
|
| | void test_UnitInDenominator() |
| | { |
| | auto result = qsb->valueFromText("1/10mm"); |
| | QCOMPARE(result, Base::Quantity(0.1, "mm")); |
| | } |
| |
|
| | void test_KeepFormat() |
| | { |
| | auto quant = qsb->value(); |
| | auto format = quant.getFormat(); |
| | format.setPrecision(7); |
| | quant.setFormat(format); |
| |
|
| | qsb->setValue(quant); |
| |
|
| | auto val1 = qsb->value(); |
| | QCOMPARE(val1.getFormat().getPrecision(), 7); |
| |
|
| | |
| | qsb->setValue(3.5); |
| | auto val2 = qsb->value(); |
| | QCOMPARE(val2.getFormat().getPrecision(), 7); |
| | } |
| |
|
| | private: |
| | std::unique_ptr<Gui::QuantitySpinBox> qsb; |
| | }; |
| |
|
| | |
| |
|
| | QTEST_MAIN(testQuantitySpinBox) |
| |
|
| | #include "QuantitySpinBox.moc" |
| |
|