--- /dev/null
+######################################################################
+# Automatically generated by qmake (2.01a) pt. pa? 8 12:09:49 2010
+######################################################################
+
+CONFIG += qtestlib core gui xml sql
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+LIBS += -lz
+
+# Input
+HEADERS += ../../src/plugins/stardict/StarDictPlugin.h \
+ ../../src/include/CommonDictInterface.h \
+ ../../src/include/translation.h \
+ ../../src/include/Notify.h \
+ ../../src/include/settings.h \
+ ../../src/include/AccentsNormalizer.h \
+ ../../src/plugins/stardict/StarDictDialog.h \
+ ../../src/include/DictDialog.h \
+ ../../src/plugins/stardict/TranslationStarDict.h \
+ ../../src/plugins/stardict/StarDictReaderFactory.h \
+ ../../src/plugins/stardict/StarDialog.h \
+ ../../src/plugins/stardict/CompressedReader.h \
+ ../../src/plugins/stardict/UncompressedReader.h \
+ ../../src/plugins/stardict/StarDictReader.h
+SOURCES += test.cpp \
+ ../../src/plugins/stardict/StarDictPlugin.cpp \
+ ../../src/plugins/stardict/CompressedReader.cpp \
+ ../../src/plugins/stardict/UncompressedReader.cpp \
+ ../../src/plugins/stardict/StarDictDialog.cpp \
+ ../../src/plugins/stardict/StarDialog.cpp \
+ ../../src/plugins/stardict/TranslationStarDict.cpp \
+ ../../src/plugins/stardict/StarDictReaderFactory.cpp
--- /dev/null
+/*******************************************************************************
+
+ This file is part of mDictionary.
+
+ mDictionary is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ mDictionary is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QList>
+#include <QByteArray>
+#include "../../src/plugins/stardict/StarDictPlugin.h"
+#include <QString>
+#include <QTest>
+#include <QtEndian>
+
+ class StarDictTests: public QObject
+ {
+ Q_OBJECT
+
+ private slots:
+ void readTest_till0();
+ void readTest_bytes();
+ void interpretTest();
+ };
+
+
+
+void StarDictTests::readTest_till0() {
+ StarDictPlugin plug;
+ QList<QByteArray> data;
+ data << "asdf\0" << "\0" << "a\0a\0" << "" << "asdf" << "╖\0" << "aᑇo\0";
+ QList<QByteArray> expected;
+ expected << "asdf" << "" << "a" << "" << "asdf" << "╖" << "aᑇo";
+ QListIterator<QByteArray> itData(data), itExpected(expected);
+
+ while(itData.hasNext()) {
+ QByteArray tmp = itData.next();
+ QCOMPARE(itExpected.next(), plug.read(tmp.begin(), tmp.end(), 0));
+ }
+
+
+}
+
+void StarDictTests::readTest_bytes() {
+ StarDictPlugin plug;
+ QList<QByteArray> data;
+ data << "asdf\0" << "\0" << "a\0a\0" << "" << "asdf" << "╖\0" << "aᑇo\0";
+ QList<QByteArray> expected;
+ expected << "asdf" << "" << "a" << "" << "asdf" << "╖" << "aᑇo";
+ QListIterator<QByteArray> itData(data), itExpected(expected);
+
+ while(itData.hasNext()) {
+ QByteArray tmp = itData.next();
+ QByteArray exp = itExpected.next();
+ QCOMPARE(exp, plug.read(tmp.begin(), tmp.end(), exp.length()));
+ }
+
+}
+
+
+void StarDictTests::interpretTest() {
+ StarDictPlugin plug;
+ QList<QByteArray> data;
+ data << "<k>a</k>sdf\0" << "\0" << "aᑇo\0" << "<k>asdf⍕ᑘቖፔ</k>\0asd"
+ << "<k>asdf⍕ᑘቖፔ</k>";
+ QList<QChar> modes;
+
+ //Test transparent modes
+ modes.clear();
+ modes << 'm' << 'l' << 't' << 'y' << 'k' << 'w' << 'h' << 'r';
+ QList<QByteArray> expected;
+ expected << "<k>a</k>sdf" << "" << "aᑇo" << "<k>asdf⍕ᑘቖፔ</k>"
+ << "<k>asdf⍕ᑘቖፔ</k>";
+ foreach(QChar mode, modes) {
+ QListIterator<QByteArray> itData(data), itExpected(expected);
+ while(itData.hasNext()) {
+ QByteArray tmp = itData.next();
+ QByteArray exp = itExpected.next();
+ QCOMPARE(QString::fromUtf8(exp), plug.interpret(tmp.begin(), tmp.end(),
+ mode, "key", false));
+ }
+ }
+
+
+ //Test pango
+ expected.clear();
+ expected << "<k>a</k>sdf" << "" << "aᑇo" << "<k>asdf⍕ᑘቖፔ</k>"
+ << "<k>asdf⍕ᑘቖፔ</k>";
+ QListIterator<QByteArray> itData = QListIterator<QByteArray>(data);
+ QListIterator<QByteArray> itExpected = QListIterator<QByteArray>(expected);
+ while(itData.hasNext()) {
+ QByteArray tmp = itData.next();
+ QByteArray exp = itExpected.next();
+ QCOMPARE("<key>key</key>" + QString::fromUtf8(exp),
+ plug.interpret(tmp.begin(), tmp.end(),
+ 'g', "key", false));
+ }
+
+
+ //Test xdxf
+ expected.clear();
+ expected << "<key>a</key><t>sdf</t>" << "" << "aᑇo"
+ << "<key>asdf⍕ᑘቖፔ</key><t></t>"
+ << "<key>asdf⍕ᑘቖፔ</key><t></t>";
+ itData = QListIterator<QByteArray>(data);
+ itExpected = QListIterator<QByteArray>(expected);
+ while(itData.hasNext()) {
+ QByteArray tmp = itData.next();
+ QByteArray exp = itExpected.next();
+ QCOMPARE(QString::fromUtf8(exp),
+ plug.interpret(tmp.begin(), tmp.end(),
+ 'x', "key", false));
+ }
+
+
+}
+
+
+QTEST_MAIN(StarDictTests)
+#include "test.moc"