From: Piotrek Date: Mon, 30 Aug 2010 07:44:00 +0000 (+0200) Subject: Merge branch 'master' of ssh://drop.maemo.org/git/mdictionary X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=bf4fc5ff9924452dcf9ab4eaefa943d79ad11074;p=mdictionary Merge branch 'master' of ssh://drop.maemo.org/git/mdictionary Conflicts: trunk/src/plugins/xdxf/tests/test.cpp trunk/src/plugins/xdxf/tests/test.h --- bf4fc5ff9924452dcf9ab4eaefa943d79ad11074 diff --cc trunk/src/plugins/xdxf/tests/test.cpp index cb6c8c5,dffbbe9..db858b2 --- a/trunk/src/plugins/xdxf/tests/test.cpp +++ b/trunk/src/plugins/xdxf/tests/test.cpp @@@ -275,23 -319,47 +319,64 @@@ void XdxfTest::timeCacheNormalize() File.close(); } +void XdxfTest::removeAccents() +{ + XdxfPluginSub xdxf; + xdxf.settings()->setValue(QString("strip_accents"), QString("true")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nóżka")), QString("nozka")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("motor")), QString("motor")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("nÓżKa")), QString("nozka")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("ławka")), QString("lawka")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("éàèùâêîôûëïüÿäöüç")), QString("eaeuaeioueiuyaouc")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("íőűúó")), QString("iouuo")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("-ę")), QString("-e")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\"e\"")), QString("\"e\"")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("'e'")), QString("'e'")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\\e")), QString("e")); + QCOMPARE(xdxf.getRemoveAccents(QString::fromUtf8("\\")), QString("")); +} + + void XdxfTest::timeFileNormalize(){ + QTime timer; + QDate date; + QFile File("../tests/time.xml"); + if(!File.open(QFile::ReadWrite | QFile::Text)) { + qDebug()<<"Error: could not open file"; + return; + } + QTextStream out(&File); + while(!out.atEnd()) + out.seek(out.pos()+1); + + XdxfPlugin xdxfPluginB(this); + Settings *settings=new Settings; + settings->setValue("path","../../../../../../dict.xdxf"); + settings->setValue("strip_accents", "true"); + CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings); + + timer.start(); + xdxfPlugin->search("Bantu"); + out<<"\n SearchFile-begin with strip accent "; + + timer.start(); + xdxfPlugin->search("level"); + out<<"\n SearchFile-midle with strip accent "; + + timer.start(); + xdxfPlugin->search("zoril"); + out<<"\n SearchFile-end with strip accent "; + + timer.start(); + xdxfPlugin->searchWordList("level"); + out<<"\n SearchWordListFile with strip accent \n"; + + File.close(); + + } QTEST_MAIN(XdxfTest) //#include "testqstring.moc" diff --cc trunk/src/plugins/xdxf/tests/test.h index 7a1f43b,f4fed84..a88d6a7 --- a/trunk/src/plugins/xdxf/tests/test.h +++ b/trunk/src/plugins/xdxf/tests/test.h @@@ -49,17 -49,8 +49,19 @@@ void searchWordListCache(); void timeCache(); void timeFile(); + void removeAccents(); + }; + + class XdxfPluginSub : public XdxfPlugin + { + public: + XdxfPluginSub(QObject *parent = 0) : XdxfPlugin(parent){} + QString getRemoveAccents(QString s) + { + return removeAccents(s); + } + void timeCacheNormalize(); + void timeFileNormalize(); };