[Kmymoney-devel] csvimport plugin test is translation dependent

Cristian Oneţ onet.cristian at gmail.com
Thu Sep 16 19:45:19 CEST 2010


2010/9/16 Alvaro Soliverez <asoliverez at kde.org>:
> Comment out the short month test for now.
>
> Anyway, the test is inherently translation dependent, but it is
> supposed to work ok. That is, until someone screwed up when
> translating to Romanian. :/

I've done that but if it can't be rewritten in a translation
independent manner I would prefer to remove it.

> On Thu, Sep 16, 2010 at 2:25 PM, Cristian Oneţ <onet.cristian at gmail.com> wrote:
>> Hi Allan,
>>
>> Can you please check the test related fix in this commit. If the test
>> can't be written in a translation independent manner then it should be
>> removed.
>>
>> Regards,
>> Cristian
>>
>> SVN commit 1176100 by conet:
>>
>> Fix compilation errors on MSVC due to a rather strange way of using
>> QStringList. I think that the code using QStringList should have been
>> more like the one in this patch. Also I commented out a test case
>> which was failing in Romanian since it was locale dependent (the short
>> month name returned 'nov.' which produced '5-nov.-1999' which can't pe
>> parsed)
>>
>>  M  +13 -13    convdate.cpp
>>  M  +4 -2      csvdatetest.cpp
>>  M  +3 -3      csvprocessing.cpp
>>  M  +4 -4      investprocessing.cpp
>>
>>
>> --- trunk/extragear/office/kmymoney/kmymoney/plugins/csvimport/convdate.cpp
>> #1176099:1176100
>> @@ -44,25 +44,25 @@
>>   QString buffer = txt;
>>   buffer = buffer.replace(rx, QString('/'));//    ....with '/'
>>
>> -  QStringList dateSplit[3] = buffer.split('/');
>> -  if (dateSplit[0].count() != 3) {//                          not a valid date
>> +  QStringList dateSplit = buffer.split('/');
>> +  if (dateSplit.count() != 3) {//                          not a valid date
>>     return QDate();
>>   }
>>   switch (m_dateFormatIndex) {
>>     case(0):    //                                          %y %m %d
>> -      aYear =  dateSplit[0].at(0);
>> -      aMonth = dateSplit[0].at(1);
>> -      aDay =   dateSplit[0].at(2);
>> +      aYear =  dateSplit[0];
>> +      aMonth = dateSplit[1];
>> +      aDay =   dateSplit[2];
>>       break;
>>     case(1):    //                                          %m %d %y
>> -      aMonth = dateSplit[0].at(0);
>> -      aDay =   dateSplit[0].at(1);
>> -      aYear =  dateSplit[0].at(2);
>> +      aMonth = dateSplit[0];
>> +      aDay =   dateSplit[1];
>> +      aYear =  dateSplit[2];
>>       break;
>>     case(2):    //                                          %d %m %y
>> -      aDay =   dateSplit[0].at(0);
>> -      aMonth = dateSplit[0].at(1);
>> -      aYear =  dateSplit[0].at(2);
>> +      aDay =   dateSplit[0];
>> +      aMonth = dateSplit[1];
>> +      aYear =  dateSplit[2];
>>       break;
>>     default:
>>       qDebug("ConvertDate - not a valid date format");
>> @@ -93,8 +93,8 @@
>>     aMonth = '0' + aMonth;
>>     aFormat = "MM";
>>   } else if (aMonth.length() == 2) {//                     assume numeric
>> -    bool datefound = ((aMonth > "0") and(aMonth < "13"));
>> -    if (not datefound) {
>> +    bool datefound = ((aMonth > "0") && (aMonth < "13"));
>> +    if (!datefound) {
>>       return QDate();//                                        not a valid day
>>     }
>>     aFormat = "MM";//                                       aMonth is numeric
>> --- trunk/extragear/office/kmymoney/kmymoney/plugins/csvimport/csvdatetest.cpp
>> #1176099:1176100
>> @@ -68,8 +68,10 @@
>>   QVERIFY(m_convert->convertDate(QString("25-" +
>> QDate::longMonthName(12) + "-2000")) ==
>>   QDate::fromString("25/12/2000", format));//e = "25-December-2000"
>>
>> -  QVERIFY(m_convert->convertDate(QString("5-" +
>> QDate::shortMonthName(11) + "-1999")) ==
>> -  QDate::fromString("5/11/1999", format));//f = "5-Nov-1999"
>> +  // TODO: change or fix this test since it's based on localization
>> which makes it fail depending on the translation
>> +  // See qt-docs: "The month names will be localized according to the
>> system's locale settings."
>> +  //QVERIFY(m_convert->convertDate(QString("5-" +
>> QDate::shortMonthName(11) + "-1999")) ==
>> +  //QDate::fromString("5/11/1999", format));//f = "5-Nov-1999"
>>
>>   QVERIFY(m_convert->convertDate("13.09.81") ==
>>           QDate::fromString("13/09/1981", format));//g = "13.09.81"
>> --- trunk/extragear/office/kmymoney/kmymoney/plugins/csvimport/csvprocessing.cpp
>> #1176099:1176100
>> @@ -334,7 +334,7 @@
>>     }
>>   }
>>
>> -  QStringList listIn[MAXCOL] =
>> m_inBuffer.split(m_fieldDelimiterCharacter);// firstly, split on
>> m_fieldDelim_char
>> +  QStringList listIn = m_inBuffer.split(m_fieldDelimiterCharacter);//
>> firstly, split on m_fieldDelim_char
>>   QStringList listOut;
>>   QString tmp;
>>   tmp.clear();
>> @@ -625,8 +625,8 @@
>>
>>  void CsvProcessing::saveAs()
>>  {
>> -  QStringList outFile[1] = m_inFileName.split('.');
>> -  const KUrl& name = outFile[0].at(0) + ".qif";
>> +  QStringList outFile = m_inFileName.split('.');
>> +  const KUrl& name = (outFile.isEmpty() ? "CsvProcessing" :
>> outFile[0]) + ".qif";
>>
>>   QString outFileName = KFileDialog::getSaveFileName(name, "*.qif |
>> QIF Files", 0, i18n("Save QIF")
>>  #if KDE_IS_VERSION(4,4,0)
>> --- trunk/extragear/office/kmymoney/kmymoney/plugins/csvimport/investprocessing.cpp
>> #1176099:1176100
>> @@ -377,8 +377,8 @@
>>   m_investDlg->m_redefine->m_accountName.clear();
>>   m_brokerageItems = false;
>>   QString name = QDir::homePath();
>> -  QStringList outFile[1] = name.split('.');
>> -  QString outFileName = outFile[0].at(0) + ".qif";
>> +  QStringList outFile = name.split('.');
>> +  QString outFileName = (outFile.isEmpty() ? "InvestProcessing" :
>> outFile[0]) + ".qif";
>>
>>   if (!fname.isEmpty())
>>     m_inFileName  = fname;
>> @@ -865,8 +865,8 @@
>>
>>  void InvestProcessing::saveAs()
>>  {
>> -  QStringList outFile[1] = m_inFileName .split('.');
>> -  const KUrl& name = outFile[0].at(0) + ".qif";
>> +  QStringList outFile = m_inFileName .split('.');
>> +  const KUrl& name = (outFile.isEmpty() ? "InvestProcessing" :
>> outFile[0]) + ".qif";
>>
>>   QString outFileName = KFileDialog::getSaveFileName(name, "*.qif |
>> QIF Files", 0, i18n("Save QIF")
>>  #if KDE_IS_VERSION(4,4,0)
>> _______________________________________________
>> KMyMoney-devel mailing list
>> KMyMoney-devel at kde.org
>> https://mail.kde.org/mailman/listinfo/kmymoney-devel
>>
> _______________________________________________
> KMyMoney-devel mailing list
> KMyMoney-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kmymoney-devel
>


More information about the KMyMoney-devel mailing list