File indexing completed on 2024-05-12 16:43:40
0001 /* 0002 SPDX-FileCopyrightText: 2012 Thomas Baumgart <ipwizard@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2015 Christian Dávid <christian-david@web.de> 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kmymoneyutils-test.h" 0008 #include "mymoneyaccount.h" 0009 0010 #include <QTest> 0011 0012 QTEST_GUILESS_MAIN(KMyMoneyUtilsTest) 0013 0014 void KMyMoneyUtilsTest::init() 0015 { 0016 } 0017 0018 void KMyMoneyUtilsTest::cleanup() 0019 { 0020 } 0021 0022 void KMyMoneyUtilsTest::initTestCase() 0023 { 0024 } 0025 0026 void KMyMoneyUtilsTest::testNextCheckNumber() 0027 { 0028 MyMoneyAccount acc; 0029 0030 // make sure first check number is 1 0031 acc.setValue("lastNumberUsed", QString()); 0032 QVERIFY(KMyMoneyUtils::nextCheckNumber(acc) == QLatin1String("1")); 0033 0034 // a simple increment of a plain value 0035 acc.setValue("lastNumberUsed", QLatin1String("123")); 0036 QVERIFY(KMyMoneyUtils::nextCheckNumber(acc) == QLatin1String("124")); 0037 0038 // a number preceded by text 0039 acc.setValue("lastNumberUsed", QLatin1String("No 123")); 0040 QVERIFY(KMyMoneyUtils::nextCheckNumber(acc) == QLatin1String("No 124")); 0041 0042 // a number followed by text 0043 acc.setValue("lastNumberUsed", QLatin1String("123 ABC")); 0044 QVERIFY(KMyMoneyUtils::nextCheckNumber(acc) == QLatin1String("124 ABC")); 0045 0046 // a number enclosed by text 0047 acc.setValue("lastNumberUsed", QLatin1String("No 123 ABC")); 0048 QVERIFY(KMyMoneyUtils::nextCheckNumber(acc) == QLatin1String("No 124 ABC")); 0049 0050 // a number containing a dash (e.g. invoice number) 0051 acc.setValue("lastNumberUsed", QLatin1String("No 123-001 ABC")); 0052 QVERIFY(KMyMoneyUtils::nextCheckNumber(acc) == QLatin1String("No 123-002 ABC")); 0053 0054 // a number containing a dot (e.g. invoice number) 0055 acc.setValue("lastNumberUsed", QLatin1String("2012.001")); 0056 QVERIFY(KMyMoneyUtils::nextCheckNumber(acc) == QLatin1String("2012.002")); 0057 0058 }