refaktoring
[mdictionary] / tests / XdxfPluginTests / test.cpp
index 8cb0a2e..b6f4b70 100644 (file)
@@ -134,6 +134,9 @@ void XdxfTest::searchWordListCache(){
         QCOMPARE(te11.at(0)->key(), QString("house"));
 
     xdxfPlugin->clean();
+    QList<Translation*> te12 = xdxfPlugin->searchWordList("1",10);
+        QCOMPARE(te2.size(), 5);
+
     delete xdxfPlugin;
 
 }
@@ -211,11 +214,46 @@ void XdxfTest::langFrom() {
     delete settings;
 
     QCOMPARE(xdxfPlugin->langFrom(), QString("ENG"));
+    QCOMPARE(xdxfPlugin->langTo(), QString("POL"));
+    QCOMPARE(xdxfPlugin->name(), QString("English-Polish dictionary"));
+    QCOMPARE(xdxfPlugin->infoNote(), QString("Copyright: http://www.freelang.net/dictionary/; Version: 1.0"));
+    QCOMPARE(xdxfPlugin->type(), QString("xdxf"));
 
     xdxfPlugin->clean();
     delete xdxfPlugin;
 }
 
+void XdxfTest::isAvailable() {
+    XdxfPlugin xdxfPluginB(this);
+    Settings *settings=new Settings;
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
+    CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+    delete settings;
+
+    QCOMPARE(xdxfPlugin->isAvailable(), true);
+
+    xdxfPlugin->clean();
+    delete xdxfPlugin;
+}
+
+void  XdxfTest::removeAccents() {
+    qDebug()<<"\n";
+    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::timeCache() {
     qDebug()<<"\n";
     QTime timer;
@@ -225,7 +263,7 @@ void XdxfTest::timeCache() {
         qDebug()<<"Error: could not open file";
         return;
     }
-    if(!QFile::exists("../../../../../../dict.xdxf")) {
+    if(!QFile::exists("../../../dict.xdxf")) {
         qDebug()<<"Error: could not open dict file";
         return;
     }
@@ -236,7 +274,7 @@ void XdxfTest::timeCache() {
     timer.start();
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("path","../../../dict.xdxf");
     settings->setValue("generateCache", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
@@ -274,13 +312,12 @@ void XdxfTest::timeCache() {
 void XdxfTest::timeFile() {
     qDebug()<<"\n";
     QTime timer;
-    QDate date;
     QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
     }
-    if(!QFile::exists("../../../../../../dict.xdxf")) {
+    if(!QFile::exists("../../../dict.xdxf")) {
         qDebug()<<"Error: could not open dict file";
         return;
     }
@@ -290,9 +327,9 @@ void XdxfTest::timeFile() {
 
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    if(!QFile::exists("../../../../../../dict.xdxf"))
+    if(!QFile::exists("../../../dict.xdxf"))
         return;
-    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("path","../../../dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -324,13 +361,12 @@ void XdxfTest::timeFile() {
 void  XdxfTest::timeCacheNormalize() {
     qDebug()<<"\n";
     QTime timer;
-    QDate date;
     QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
     }
-    if(!QFile::exists("../../../../../../dict.xdxf")) {
+    if(!QFile::exists("../../../dict.xdxf")) {
         qDebug()<<"Error: could not open dict file";
         return;
     }
@@ -342,7 +378,7 @@ void  XdxfTest::timeCacheNormalize() {
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
 
-    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("path","../../../dict.xdxf");
     settings->setValue("generateCache", "true");
     settings->setValue("strip_accents", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
@@ -376,34 +412,15 @@ void  XdxfTest::timeCacheNormalize() {
     delete xdxfPlugin;
 }
 
-void  XdxfTest::removeAccents() {
-    qDebug()<<"\n";
-    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(){
     qDebug()<<"\n";
     QTime timer;
-    QDate date;
     QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
     }
-    if(!QFile::exists("../../../../../../dict.xdxf")) {
+    if(!QFile::exists("../../../dict.xdxf")) {
         qDebug()<<"Error: could not open dict file";
         return;
     }
@@ -413,7 +430,7 @@ void XdxfTest::timeFileNormalize(){
 
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../../../../../../dict.xdxf");
+    settings->setValue("path","../../../dict.xdxf");
     settings->setValue("strip_accents", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;