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
|
/*
SPDX-FileCopyrightText: 2014 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "kpluralhandlingspinboxtest.h"
#include "kpluralhandlingspinbox.h"
#include <QTest>
QTEST_MAIN(KPluralHandlingSpinBoxTest)
KPluralHandlingSpinBoxTest::KPluralHandlingSpinBoxTest()
{
}
void KPluralHandlingSpinBoxTest::shouldHaveDefautValue()
{
KPluralHandlingSpinBox spinbox;
QCOMPARE(spinbox.suffix(), QString());
}
void KPluralHandlingSpinBoxTest::shouldUseSingularValueWhenUseValueEqualToOne()
{
KPluralHandlingSpinBox spinbox;
spinbox.setSuffix(ki18np("singular", "plural"));
spinbox.setValue(1);
QCOMPARE(spinbox.suffix(), QLatin1String("singular"));
}
void KPluralHandlingSpinBoxTest::shouldUsePlurialValueWhenUseValueSuperiorToOne()
{
KPluralHandlingSpinBox spinbox;
spinbox.setSuffix(ki18np("singular", "plural"));
spinbox.setValue(2);
QCOMPARE(spinbox.suffix(), QLatin1String("plural"));
}
void KPluralHandlingSpinBoxTest::shouldUseSingularValueWhenWeChangeValueAndFinishWithValueEqualOne()
{
KPluralHandlingSpinBox spinbox;
spinbox.setSuffix(ki18np("singular", "plural"));
spinbox.setValue(2);
spinbox.setValue(1);
QCOMPARE(spinbox.suffix(), QLatin1String("singular"));
QCOMPARE(spinbox.value(), 1);
}
void KPluralHandlingSpinBoxTest::shouldReturnEmptySuffix()
{
KPluralHandlingSpinBox spinbox;
spinbox.setValue(2);
QCOMPARE(spinbox.suffix(), QString());
}
#include "moc_kpluralhandlingspinboxtest.cpp"
|