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","../tests/dict.xdxf");
30 CommonDictInterface *xdxfPlugin2 = xdxfPlugin.getNew(settings);
31 QList<Translation*> te6=xdxfPlugin2->searchWordList("*",8);
32 QCOMPARE(te6.size(),8);
35 void XdxfTest::search() {
36 /*test for English-Polish dictionary */
37 XdxfPlugin xdxfPluginB(this);
41 Settings *settings=new Settings;
42 settings->setValue("path","../tests/dict.xdxf");
43 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
45 xdxfPlugin->search("wino");
46 QCOMPARE(xdxfPlugin->search("."), QString("kropka\n"));
47 QCOMPARE(xdxfPlugin->search("1"), QString("one\n"));
50 void XdxfTest::searchWordList() {
51 /*test for English-Polish dictionary */
52 XdxfPlugin xdxfPluginB(this);
54 Settings *settings=new Settings;
55 settings->setValue("path","../tests/dict.xdxf");
56 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
57 QList<Translation*> te = xdxfPlugin->searchWordList(".", 10);
59 QCOMPARE(te.size(), 8);
60 QList<Translation*> te2 = xdxfPlugin->searchWordList("1",10);
61 QCOMPARE(te2.size(), 5);
63 QList<Translation*> te3 = xdxfPlugin->searchWordList("1", 2);
64 QCOMPARE(te3.size(), 2);
66 QList<Translation*> te4 = xdxfPlugin->searchWordList("ho*SE", 10);
67 QCOMPARE(te4.at(0)->key(), QString("house"));
69 QList<Translation*> te5 = xdxfPlugin->searchWordList("*");
70 QCOMPARE(te5.size(), 8);
72 QList<Translation*> te6 = xdxfPlugin->searchWordList("*", 8);
73 QCOMPARE(te6.size(), 8);
75 QList<Translation*> te7 = xdxfPlugin->searchWordList("*ou*");
76 QCOMPARE(te7.at(0)->key(), QString("house"));
78 QList<Translation*> te8 = xdxfPlugin->searchWordList("1?");
79 QCOMPARE(te8.at(0)->key(), QString("10"));
81 QList<Translation*> te9 = xdxfPlugin->searchWordList("1???");
82 QCOMPARE(te9.at(0)->key(), QString("1000"));
84 QList<Translation*> te10 = xdxfPlugin->searchWordList("1????*");
85 QCOMPARE(te10.at(0)->key(), QString("1 000 000"));
87 QList<Translation*> te11 = xdxfPlugin->searchWordList("h**?*?**e");
88 QCOMPARE(te11.at(0)->key(), QString("house"));
93 void XdxfTest::stop() {
94 /*test for English-Polish dictionary */
95 XdxfPlugin xdxfPluginB(this);
96 // xdxfPlugin.setPatch("dict.xdxf");
98 Settings *settings=new Settings;
99 settings->setValue("path","../tests/dict.xdxf");
100 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
103 QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
104 QList<Translation*> te5 = future.result();
106 QCOMPARE(te5.size(), 8);
110 void XdxfTest::langFrom() {
111 /*test for English-Polish dictionary */
112 XdxfPlugin xdxfPluginB(this);
113 // xdxfPlugin.setPatch("dict.xdxf");
115 Settings *settings=new Settings;
116 settings->setValue("path","../tests/dict.xdxf");
117 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
118 xdxfPlugin->searchWordList("rope", 10);
119 QCOMPARE(xdxfPlugin->langFrom(), QString("ENG"));
123 //#include "testqstring.moc"