From: Reto Zingg Date: Sat, 13 Mar 2010 20:42:53 +0000 (+0200) Subject: updated tests X-Git-Tag: version-0.0.2-combo~9 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=79fd3bdb574e363f2ef77744acaa3362227a1916;p=qtvoc.git updated tests --- diff --git a/lib/tests/tests.cpp b/lib/tests/tests.cpp index fe02026..ed777a1 100644 --- a/lib/tests/tests.cpp +++ b/lib/tests/tests.cpp @@ -5,9 +5,11 @@ #include "keduvocdocument.h" #include "keduvoclesson.h" #include "keduvocexpression.h" +#include "keduvocleitnerbox.h" #include - +#include +#include class RmzTest : public QObject { @@ -29,6 +31,13 @@ private slots: const QString comment = QString::fromLatin1( "comment" ); const QString category = QString::fromLatin1( "test document" ); const QString title = QString::fromLatin1( "Validator Test Title" ); + const QString lang1 = QString::fromLatin1( "English" ); + const QString lang2 = QString::fromLatin1( "German" ); + const QString locale1 = QString::fromLatin1( "en" ); + const QString locale2 = QString::fromLatin1( "de" ); + const QString translation1 = QString::fromLatin1( "this is English" ); + const QString translation2 = QString::fromLatin1( "das ist Deutsch" ); + const QString lessonName = QString::fromLatin1( "Lesson No 1" ); KEduVocDocument doc; doc.setAuthor( author ); @@ -39,31 +48,49 @@ private slots: doc.appendIdentifier(); doc.appendIdentifier(); - doc.identifier(0).setName("0"); - doc.identifier(1).setName("1"); - - KEduVocLesson* lesson = new KEduVocLesson("lesson", doc.lesson()); + doc.identifier(0).setName( lang1 ); + doc.identifier(0).setLocale( locale1 ); + doc.identifier(1).setName( lang2 ); + doc.identifier(1).setLocale( locale2 ); + + KEduVocLesson* lesson = new KEduVocLesson(lessonName, doc.lesson()); doc.lesson()->appendChildContainer(lesson); lesson->appendEntry(new KEduVocExpression); - lesson->entry(0)->setTranslation(0, "0"); - lesson->entry(0)->setTranslation(1, "1"); - + lesson->entry(0)->setTranslation(0, translation1); + lesson->entry(0)->setTranslation(1, translation2); + doc.saveAs(fileName, KEduVocDocument::Kvtml, generator); - + KEduVocDocument docRead; docRead.open(fileName); + + + + QList lessons = docRead.lesson()->childContainers(); + KEduVocLesson *m_lesson; + + foreach(KEduVocContainer * c, lessons) { + if (c->containerType() == KEduVocLesson::Lesson) { + m_lesson = static_cast(c); + } + } + QCOMPARE( docRead.generator(), generator ); QCOMPARE( docRead.author(), author ); QCOMPARE( docRead.license(), license ); QCOMPARE( docRead.documentComment(), comment ); QCOMPARE( docRead.category(), category ); QCOMPARE( docRead.title(), title ); - QCOMPARE(doc.identifierCount(), 2); - QCOMPARE(lesson->entry(0)->translationIndices().size(), 2); - QCOMPARE(lesson->entry(0)->translation(0)->text(), QString("0")); - QCOMPARE(lesson->entry(0)->translation(1)->text(), QString("1")); - + QCOMPARE( docRead.identifierCount(), 2); + QCOMPARE( docRead.identifier(0).name(), lang1); + QCOMPARE( docRead.identifier(1).name(), lang2); + QCOMPARE( docRead.identifier(0).locale(), locale1); + QCOMPARE( docRead.identifier(1).locale(), locale2); + QCOMPARE( m_lesson->name(), lessonName); + QCOMPARE( m_lesson->entry(0)->translationIndices().size(), 2); + QCOMPARE( m_lesson->entry(0)->translation(0)->text(), translation1); + QCOMPARE( m_lesson->entry(0)->translation(1)->text(), translation2); } }; diff --git a/lib/tests/tests.kvtml b/lib/tests/tests.kvtml new file mode 100644 index 0000000..b213355 --- /dev/null +++ b/lib/tests/tests.kvtml @@ -0,0 +1,40 @@ + + + + + Validator Unit Tests + Validator Test Title + Validator Test + test license + comment + 2010-03-13 + test document + + + + English + en + + + German + de + + + + + + this is English + + + das ist Deutsch + + + + + + lesson No 1 + true + + + + diff --git a/lib/tests/tests.pro b/lib/tests/tests.pro index 2c41990..ed9f625 100644 --- a/lib/tests/tests.pro +++ b/lib/tests/tests.pro @@ -8,7 +8,7 @@ DEPENDPATH += . ../ INCLUDEPATH += . ../ LIBS += -L../ -lkeduvocdocument QT += core testlib -CONFIG +=qtestlib +CONFIG += qtestlib # Input SOURCES += tests.cpp