fix locale test for money formatting;
authorKonrad Rosenbaum <konrad@silmor.de>
Sun, 28 Apr 2013 11:28:13 +0000 (13:28 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Sun, 28 Apr 2013 11:49:12 +0000 (13:49 +0200)
fix config location for tests;
add run script for tests

src/main.cpp
tests/locale/tlocale.cpp
tests/mtest.h
tests/runtests.sh [new file with mode: 0755]

index 9a14b2a..b1fef62 100644 (file)
@@ -257,7 +257,7 @@ MApplication::MApplication(int&ac,char**av)
         installEventFilter(ef=new EFilter);
         
         //check parameters
-        qDebug()<<"arguments"<<arguments();
+//         qDebug()<<"arguments"<<arguments();
         for(const QString& param:arguments()){
                 if(param.startsWith("-confdir=")){
                         setConfigDir(param.mid(9));
@@ -274,8 +274,9 @@ MApplication::MApplication(int&ac,char**av)
 void MApplication::setConfigDir(QString d)
 {
         QSettings::setDefaultFormat(QSettings::IniFormat);
-        QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,resolveDir(d));
-        qDebug()<<"Setting the config directory to"<<::dataDir<<"from"<<d;
+        const QString cdir=resolveDir(d);
+        QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,cdir);
+        qDebug()<<"Setting the config directory to"<<cdir<<"from"<<d;
 }
 
 void MApplication::setDataDir(QString d)
index 3239d10..649aa0f 100644 (file)
@@ -17,6 +17,7 @@
 MSTEST_MAIN(TLocale)
 
 
+
 void TLocale::printFormatting()
 {
         QCOMPARE(mf.formatNumber(10000),(QString)"10000");
@@ -88,7 +89,7 @@ void TLocale::weirdMoneyRegexp()
         QVERIFY(!r.exactMatch("123.45x"));
         QVERIFY(r.exactMatch("123;456Credits"));
         QVERIFY(r.exactMatch("[123;456]Credits"));
-        QVERIFY(!r.exactMatch("-123;456Credits"));
+        QVERIFY(r.exactMatch("-123;456Credits"));
 }
 
 
@@ -149,8 +150,8 @@ void TLocale::weirdScanData()
         QCOMPARE(mf.scanMoney(" -12,34.56 "),-12000ll);
         QCOMPARE(mf.scanMoney(" [12,34.56] "),-12000ll);
         QCOMPARE(mf.scanMoney(" [12_34;56]Cu "),-1234560ll);
-        QCOMPARE(mf.scanMoney(" -12_34;56Cu "),0ll);
-        QCOMPARE(mf.scanMoney(" -[12_34;56]Cu "),0ll);
+        QCOMPARE(mf.scanMoney(" -12_34;56Cu "),-1234560ll);
+        QCOMPARE(mf.scanMoney(" -[12_34;56]Cu "),-1234560ll);
 }
 
 
@@ -192,8 +193,9 @@ void TLocale::switchToBadFormat()
         mf.setShortMonths(QStringList()<<"j1"<<"f2"<<"m3"<<"a4"<<"m5"<<"j6"<<"j7"<<"a8"<<"s9"<<"o10"<<"n11"<<"d12");
         qDebug()<<"decimal dot=; thousand divider=_ 2 digits per block";
         mf.setNumberFormat(';','_',2);
-        qDebug()<<"currency=Credits, 3 currency decimals, negative is [123.45]";
-        mf.setMoneyFormat("Credits",3,"[]");
+        qDebug()<<"currency=Credits, 3 currency decimals, negative is [123;45]";
+        mf.setMoneyFormat("Credits",3,true);
+        mf.setMoneySign("[]");
         mf.setAP("AA","PP");
 }
 
index 5597dfd..d359d39 100644 (file)
@@ -8,6 +8,8 @@
 int main(int argc, char *argv[]) \
 { \
     MApplication app(argc, argv); \
+    app.setConfigDir("$APP/appconf");\
+    app.setDataDir("$APP/appdata");\
     app.setAttribute(Qt::AA_Use96Dpi, true); \
     QTEST_DISABLE_KEYPAD_NAVIGATION \
     TestObject tc; \
diff --git a/tests/runtests.sh b/tests/runtests.sh
new file mode 100755 (executable)
index 0000000..5ce321c
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+###########################################################
+# Test Runner Script for MagicSmoke
+###########################################################
+
+
+cd `dirname $0`
+
+TASKS="
+test_locale
+"
+
+rm -f test_*.xml
+
+for tcase in $TASKS ; do
+  ./$tcase -xunitxml >$tcase.xml
+done