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"));
49 QCOMPARE(xdxfPlugin->search("test"), QString("<pos>krowa</pos>test01\n"));
52 void XdxfTest::searchWordList() {
53 /*test for English-Polish dictionary */
54 XdxfPlugin xdxfPluginB(this);
56 Settings *settings=new Settings;
57 settings->setValue("path","../tests/dict.xdxf");
58 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
59 QList<Translation*> te = xdxfPlugin->searchWordList(".", 10);
61 QCOMPARE(te.size(), 9);
62 QList<Translation*> te2 = xdxfPlugin->searchWordList("1",10);
63 QCOMPARE(te2.size(), 5);
65 QList<Translation*> te3 = xdxfPlugin->searchWordList("1", 2);
66 QCOMPARE(te3.size(), 2);
68 QList<Translation*> te4 = xdxfPlugin->searchWordList("ho*SE", 10);
69 QCOMPARE(te4.at(0)->key(), QString("house"));
71 QList<Translation*> te5 = xdxfPlugin->searchWordList("*");
72 QCOMPARE(te5.size(), 9);
74 QList<Translation*> te6 = xdxfPlugin->searchWordList("*", 8);
75 QCOMPARE(te6.size(), 8);
77 QList<Translation*> te7 = xdxfPlugin->searchWordList("*ou*");
78 QCOMPARE(te7.at(0)->key(), QString("house"));
80 QList<Translation*> te8 = xdxfPlugin->searchWordList("1?");
81 QCOMPARE(te8.at(0)->key(), QString("10"));
83 QList<Translation*> te9 = xdxfPlugin->searchWordList("1???");
84 QCOMPARE(te9.at(0)->key(), QString("1000"));
86 QList<Translation*> te10 = xdxfPlugin->searchWordList("1????*");
87 QCOMPARE(te10.at(0)->key(), QString("1 000 000"));
89 QList<Translation*> te11 = xdxfPlugin->searchWordList("h**?*?**e");
90 QCOMPARE(te11.at(0)->key(), QString("house"));
95 void XdxfTest::stop() {
96 /*test for English-Polish dictionary */
97 XdxfPlugin xdxfPluginB(this);
98 // xdxfPlugin.setPatch("dict.xdxf");
100 Settings *settings=new Settings;
101 settings->setValue("path","../tests/dict.xdxf");
102 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
105 QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
106 QList<Translation*> te5 = future.result();
108 QCOMPARE(te5.size(), 9);
112 void XdxfTest::langFrom() {
113 /*test for English-Polish dictionary */
114 XdxfPlugin xdxfPluginB(this);
115 // xdxfPlugin.setPatch("dict.xdxf");
117 Settings *settings=new Settings;
118 settings->setValue("path","../tests/dict.xdxf");
119 CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
120 xdxfPlugin->searchWordList("rope", 10);
121 QCOMPARE(xdxfPlugin->langFrom(), QString("ENG"));
125 //#include "testqstring.moc"