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::search() {
26 /*test for English-Polish dictionary */
27 XdxfPlugin xdxfPlugin(this);
28 xdxfPlugin.setPatch("dict.xdxf");
29 xdxfPlugin.search("wino");
30 QCOMPARE(xdxfPlugin.search("."), QString("kropka\n"));
31 QCOMPARE(xdxfPlugin.search("1"), QString("one\n"));
34 void XdxfTest::searchWordList() {
35 /*test for English-Polish dictionary */
36 XdxfPlugin xdxfPlugin(this);
37 xdxfPlugin.setPatch("dict.xdxf");
38 QList<Translation*> te=xdxfPlugin.searchWordList(".",10);
40 QCOMPARE(te.at(0)->key(), QString("."));
41 QList<Translation*> te2=xdxfPlugin.searchWordList("1",10);
42 QCOMPARE(te2.size(),5);
44 QList<Translation*> te3=xdxfPlugin.searchWordList("1",2);
45 QCOMPARE(te3.size(),2);
47 QList<Translation*> te4=xdxfPlugin.searchWordList("ho*SE",10);
48 QCOMPARE(te4.at(0)->key(), QString("house"));
50 QList<Translation*> te5=xdxfPlugin.searchWordList("*");
51 QCOMPARE(te5.size(),8);
53 QList<Translation*> te6=xdxfPlugin.searchWordList("*",8);
54 QCOMPARE(te6.size(),8);
58 void XdxfTest::stop() {
59 /*test for English-Polish dictionary */
60 CommonDictInterface *xdxfPlugin = new XdxfPlugin(this);
61 xdxfPlugin.setPatch("dict.xdxf");
64 QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
65 QList<Translation*> te5 = future.result();
67 QCOMPARE(te5.size(),8);
70 void XdxfTest::getNew() {
71 XdxfPlugin xdxfPlugin(this);
72 Settings *settings=new Settings;
73 settings->setValue("path","dict.xdxf");
74 CommonDictInterface *xdxfPlugin2 = xdxfPlugin.getNew(settings);
75 QList<Translation*> te6=xdxfPlugin2->searchWordList("*",8);
76 QCOMPARE(te6.size(),8);
79 void XdxfTest::langFrom() {
80 /*test for English-Polish dictionary */
81 XdxfPlugin xdxfPlugin(this);
82 xdxfPlugin.setPatch("dict.xdxf");
83 xdxfPlugin.searchWordList("rope",10);
84 QCOMPARE(xdxfPlugin.langFrom(), QString("ENG"));
88 //#include "testqstring.moc"