Merge branch 'master' of ssh://drop.maemo.org/git/mdictionary
[mdictionary] / trunk / src / plugins / xdxf / tests / test.cpp
index cb6c8c5..db858b2 100644 (file)
@@ -186,8 +186,7 @@ void XdxfTest::langFrom() {
     delete xdxfPlugin;
 }
 
-void XdxfTest::timeCache()
-{
+void XdxfTest::timeCache() {
     QTime timer;
     QDate date;
     QFile File("../tests/time.xml");
@@ -234,8 +233,7 @@ void XdxfTest::timeCache()
     File.close();
 }
 
-void XdxfTest::timeFile()
-{
+void XdxfTest::timeFile() {
     QTime timer;
     QDate date;
     QFile File("../tests/time.xml");
@@ -270,7 +268,53 @@ void XdxfTest::timeFile()
     timer.start();
     xdxfPlugin->searchWordList("level");
     out<<"\n<type> SearchWordListFile </type> <time>" << timer.elapsed();
-    out<< "</time>\n";
+    out<< "</time>";
+
+    File.close();
+}
+
+void XdxfTest::timeCacheNormalize() {
+    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);
+
+    timer.start();
+    XdxfPlugin xdxfPluginB(this);
+    Settings *settings=new Settings;
+    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("generateCache", "true");
+    settings->setValue("strip_accents", "true");
+    CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+
+    out<<"\n<type> Cache with strip accent </type> <time>" << timer.elapsed();
+    out<<"</time>";
+
+    timer.start();
+    xdxfPlugin->search("Bantu");
+    out<<"\n<type> SearchCache-begin with strip accent </type> <time>" << timer.elapsed();
+    out<< "</time>";
+
+    timer.start();
+    xdxfPlugin->search("level");
+    out<<"\n<type> SearchCache-midle with strip accent </type> <time>" << timer.elapsed();
+    out<< "</time>";
+
+    timer.start();
+    xdxfPlugin->search("zoril");
+    out<<"\n<type> SearchCache-end with strip accent </type> <time>" << timer.elapsed();
+    out<< "</time>";
+
+    timer.start();
+    xdxfPlugin->searchWordList("level");
+    out<<"\n<type> SearchWorlListCache with strip accent </type> <time>" << timer.elapsed();
+    out<< "</time>";
 
     File.close();
 }
@@ -292,6 +336,47 @@ void XdxfTest::removeAccents()
     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<type> SearchFile-begin with strip accent </type> <time>" << timer.elapsed();
+    out << "</time>";
+
+    timer.start();
+    xdxfPlugin->search("level");
+    out<<"\n<type> SearchFile-midle with strip accent </type> <time>" << timer.elapsed();
+    out << "</time>";
+
+    timer.start();
+    xdxfPlugin->search("zoril");
+    out<<"\n<type> SearchFile-end with strip accent </type> <time>" << timer.elapsed();
+    out << "</time>";
+
+    timer.start();
+    xdxfPlugin->searchWordList("level");
+    out<<"\n<type> SearchWordListFile with strip accent </type> <time>" << timer.elapsed();
+    out<< "</time>\n";
+
+    File.close();
+
+}
 
 QTEST_MAIN(XdxfTest)
 //#include "testqstring.moc"