in XdxfPlugin in function searchWordList add unlimited number of words
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 6 Aug 2010 08:02:25 +0000 (10:02 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 6 Aug 2010 08:02:25 +0000 (10:02 +0200)
trunk/src/plugins/xdxf/src/xdxfplugin.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.h
trunk/src/plugins/xdxf/tests/test.cpp
trunk/src/plugins/xdxf/tests/test.h
trunk/src/plugins/xdxf/tests/unit_tests.pro

index bc0622e..91f24fe 100644 (file)
@@ -104,7 +104,7 @@ QList<Translation*> XdxfPlugin::searchWordList(QString word, int limit) {
                 dictionaryReader.readNextStartElement();
             if(!dictionaryReader.atEnd())
                 a = dictionaryReader.readElementText();
-            if(regWord.exactMatch(a) && i<limit) {
+            if(regWord.exactMatch(a) && (i<limit || limit==0)) {
                 bool ok=true;
                 Translation *tran;
                 foreach(tran,translations)
@@ -155,7 +155,7 @@ QString XdxfPlugin::search(QString key) {
                         temp+=dictionaryReader.text().toString();
                     }
                 }
-                resultString+=temp.replace("\n","");
+                resultString+=temp.replace("\n","")+"\n";
                 match=false;
             }
         }
index ce2dbca..0786330 100644 (file)
@@ -85,7 +85,7 @@ public Q_SLOTS:
       After finishing search it has to emit
       \see CommonDictInterface:finalTranslation  finalTranslation
     */
-    QList<Translation*> searchWordList(QString word, int limit);
+    QList<Translation*> searchWordList(QString word, int limit=0);
 
     //! stop current operation
     void stop();
index c5d5337..8ecf8bc 100644 (file)
 #include "test.h"
 #include <QSignalSpy>
 
-void Testowanie::search()
-{
+void Testowanie::search() {
+    /*test for English-Polish dictionary */
     XdxfPlugin xdxfPlugin(this);
     xdxfPlugin.search("wino");
-//   QCOMPARE(xdxfPlugin.search("afera"), QString("scam"));
-//   QCOMPARE(xdxfPlugin.search("grzech"), QString("sin"));
-    QCOMPARE(xdxfPlugin.search("Advent"), QString("Adwent"));
+   QCOMPARE(xdxfPlugin.search("."), QString("kropka\n"));
+   QCOMPARE(xdxfPlugin.search("1"), QString("one\n"));
 }
 
-void Testowanie::searchWordList()
-{
+void Testowanie::searchWordList() {
+     /*test for English-Polish dictionary */
     XdxfPlugin xdxfPlugin(this);
-    QList<Translation*> te=xdxfPlugin.searchWordList("Adventeee",10);
+    QList<Translation*> te=xdxfPlugin.searchWordList(".",10);
     if(te.size()>0)
-        QCOMPARE(te.at(0)->key(), QString("Advent"));
+        QCOMPARE(te.at(0)->key(), QString("."));
+    QList<Translation*> te2=xdxfPlugin.searchWordList("1",10);
+    QCOMPARE(te2.size(),5);
+
+    QList<Translation*> te3=xdxfPlugin.searchWordList("1",2);
+    QCOMPARE(te3.size(),2);
+
+    QList<Translation*> te4=xdxfPlugin.searchWordList("ho*SE",10);
+        QCOMPARE(te4.at(0)->key(), QString("house"));
+
+    QList<Translation*> te5=xdxfPlugin.searchWordList("*",0);
+        QCOMPARE(te5.size(),8);
+
+    QList<Translation*> te6=xdxfPlugin.searchWordList("*",8);
+        QCOMPARE(te6.size(),8);
+
 }
 
-void Testowanie::langFrom()
-{
+
+void Testowanie::getNew() {
+/*    XdxfPlugin xdxfPlugin(this);
+    Settings settings;
+    settings.setValue("path","dict2");
+    XdxfPlugin * = xdxfPlugin.getNew(settings);
+*/
+}
+
+void Testowanie::langFrom() {
+     /*test for English-Polish dictionary */
     XdxfPlugin xdxfPlugin(this);
     xdxfPlugin.searchWordList("rope",10);
-    QCOMPARE(xdxfPlugin.langFrom(), QString("POL"));
+    QCOMPARE(xdxfPlugin.langFrom(), QString("ENG"));
 }
 
 QTEST_MAIN(Testowanie)
 //#include "testqstring.moc"
-
-/*duze i małe litery*/
index 45c5fd1..484d6ff 100644 (file)
 #define TEST_H
 
 #include <QtTest/QtTest>
-#include "../src/XdxfPlugin/xdxfplugin.h"
-#include "../src/XdxfPlugin/TranslationXdxf.h"
-#include "../../../includes/translation.h"
-
 #include <QList>
 #include <QTime>
 
+
+#include "../src/xdxfplugin.h"
+
  class Testowanie: public QObject
  {
      Q_OBJECT
@@ -39,6 +38,7 @@
      void search();
      void searchWordList();
      void langFrom();
+     void getNew();
  };
 
 
index f771321..4bf930c 100644 (file)
@@ -8,12 +8,18 @@ INCLUDEPATH += .
 
 # Input
 HEADERS += test.h \
-    ../src/XdxfPlugin/xdxfplugin.h \
-    ../src/XdxfPlugin/TranslationXdxf.h \
+    ../src/xdxfplugin.h \
+    ../src/TranslationXdxf.h \
     ../../../includes/translation.h \
     ../../../includes/settings.h \
-    ../../../includes/CommonDictInterface.h
+    ../../../includes/DictDialog.h \
+    ../../../includes/CommonDictInterface.h \
+    ../src/XdxfDictDialog.h \
+    ../src/XdxfLoadDialog.h
+
 
 SOURCES += test.cpp \
-    ../src/XdxfPlugin/xdxfplugin.cpp \
-    ../src/XdxfPlugin/TranslationXdxf.cpp
+    ../src/xdxfplugin.cpp \
+    ../src/TranslationXdxf.cpp \
+    ../src/XdxfLoadDialog.cpp \
+    ../src/XdxfDictDialog.cpp