add to test - search with strip_accents
[mdictionary] / trunk / src / plugins / xdxf / tests / test.cpp
index 58aeb02..dffbbe9 100644 (file)
@@ -80,7 +80,7 @@ void XdxfTest::searchWordListCache(){
 
     QList<Translation*> te = xdxfPlugin->searchWordList(".", 10);
     if(te.size()>0)
-        QCOMPARE(te.size(), 9);
+        QCOMPARE(te.size(), 1);
     QList<Translation*> te2 = xdxfPlugin->searchWordList("1",10);
     QCOMPARE(te2.size(), 5);
 
@@ -123,7 +123,7 @@ void XdxfTest::searchWordListFile() {
 
     QList<Translation*> te = xdxfPlugin->searchWordList(".", 10);
     if(te.size()>0)
-        QCOMPARE(te.size(), 9);
+        QCOMPARE(te.size(), 1);
     QList<Translation*> te2 = xdxfPlugin->searchWordList("1",10);
     QCOMPARE(te2.size(), 5);
 
@@ -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,11 +268,98 @@ 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();
 }
 
+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"