1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
25 void XdxfTest::getNew() {
26 XdxfPlugin xdxfPlugin(this);
27 Settings *settings=new Settings;
28 settings->setValue("path","dict.xdxf");
29 CommonDictInterface *xdxfPlugin2 = xdxfPlugin.getNew(settings);
30 QList<Translation*> te6=xdxfPlugin2->searchWordList("*",8);
31 QCOMPARE(te6.size(),8);
34 void XdxfTest::search() {
35 /*test for English-Polish dictionary */
36 XdxfPlugin xdxfPluginB(this);
37 // xdxfPlugin.setPatch("dict.xdxf");
39 Settings *settings=new Settings;
40 settings->setValue("path","dict.xdxf");
41 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
42 xdxfPlugin->search("wino");
43 QCOMPARE(xdxfPlugin->search("."), QString("kropka\n"));
44 QCOMPARE(xdxfPlugin->search("1"), QString("one\n"));
47 void XdxfTest::searchWordList() {
48 /*test for English-Polish dictionary */
49 XdxfPlugin xdxfPluginB(this);
50 // xdxfPlugin.setPatch("dict.xdxf");
52 Settings *settings=new Settings;
53 settings->setValue("path","dict.xdxf");
54 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
55 QList<Translation*> te=xdxfPlugin->searchWordList(".",10);
57 QCOMPARE(te.at(0)->key(), QString("."));
58 QList<Translation*> te2=xdxfPlugin->searchWordList("1",10);
59 QCOMPARE(te2.size(),5);
61 QList<Translation*> te3=xdxfPlugin->searchWordList("1",2);
62 QCOMPARE(te3.size(),2);
64 QList<Translation*> te4=xdxfPlugin->searchWordList("ho*SE",10);
65 QCOMPARE(te4.at(0)->key(), QString("house"));
67 QList<Translation*> te5=xdxfPlugin->searchWordList("*");
68 QCOMPARE(te5.size(),8);
70 QList<Translation*> te6=xdxfPlugin->searchWordList("*",8);
71 QCOMPARE(te6.size(),8);
75 void XdxfTest::stop() {
76 /*test for English-Polish dictionary */
77 XdxfPlugin xdxfPluginB(this);
78 // xdxfPlugin.setPatch("dict.xdxf");
80 Settings *settings=new Settings;
81 settings->setValue("path","dict.xdxf");
82 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
85 QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
86 QList<Translation*> te5 = future.result();
88 QCOMPARE(te5.size(),8);
92 void XdxfTest::langFrom() {
93 /*test for English-Polish dictionary */
94 XdxfPlugin xdxfPluginB(this);
95 // xdxfPlugin.setPatch("dict.xdxf");
97 Settings *settings=new Settings;
98 settings->setValue("path","dict.xdxf");
99 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
100 xdxfPlugin->searchWordList("rope",10);
101 QCOMPARE(xdxfPlugin->langFrom(), QString("ENG"));
105 //#include "testqstring.moc"