]> Git trees. - qtvoc.git/commitdiff
add unit tests version-0.0.1
authorReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 13 Mar 2010 15:14:06 +0000 (17:14 +0200)
committerReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 13 Mar 2010 15:14:06 +0000 (17:14 +0200)
lib/tests/tests.cpp [new file with mode: 0644]
lib/tests/tests.pro [new file with mode: 0644]

diff --git a/lib/tests/tests.cpp b/lib/tests/tests.cpp
new file mode 100644 (file)
index 0000000..fe02026
--- /dev/null
@@ -0,0 +1,73 @@
+
+#include <QtTest/QtTest>
+
+
+#include "keduvocdocument.h"
+#include "keduvoclesson.h"
+#include "keduvocexpression.h"
+
+#include <QTemporaryFile>
+
+
+class RmzTest : public QObject
+{
+    Q_OBJECT
+       
+private slots:
+    void rmzTestDocumentAboutInfo()
+    {
+        QTemporaryFile file("XXXXXXXX.kvtml");
+        file.open();
+        // qDebug( QString("Temp file name is: %1").arg( file.fileName() ) );
+        QUrl fileName = QUrl(file.fileName());
+        // file.setAutoRemove(0);
+        file.close();
+        
+        const QString generator = QString::fromLatin1( "Validator Unit Tests" );
+        const QString author = QString::fromLatin1( "Validator Test" );
+        const QString license = QString::fromLatin1( "test license" );
+        const QString comment = QString::fromLatin1( "comment" );
+        const QString category = QString::fromLatin1( "test document" );
+        const QString title = QString::fromLatin1( "Validator Test Title" );
+        
+        KEduVocDocument doc;
+        doc.setAuthor( author );
+        doc.setLicense( license );
+        doc.setDocumentComment( comment );
+        doc.setCategory( category );
+        doc.setTitle( title );
+        
+        doc.appendIdentifier();
+        doc.appendIdentifier();
+        doc.identifier(0).setName("0");
+        doc.identifier(1).setName("1");
+        
+        KEduVocLesson* lesson = new KEduVocLesson("lesson", doc.lesson());
+        doc.lesson()->appendChildContainer(lesson);
+        lesson->appendEntry(new KEduVocExpression);
+        lesson->entry(0)->setTranslation(0, "0");
+        lesson->entry(0)->setTranslation(1, "1");
+        
+        doc.saveAs(fileName, KEduVocDocument::Kvtml, generator);
+        
+        KEduVocDocument docRead;
+        docRead.open(fileName);
+        
+        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"));
+        
+    }
+    
+};
+
+QTEST_MAIN(RmzTest)
+
+#include "tests.moc"
\ No newline at end of file
diff --git a/lib/tests/tests.pro b/lib/tests/tests.pro
new file mode 100644 (file)
index 0000000..2c41990
--- /dev/null
@@ -0,0 +1,14 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Sat Mar 13 15:10:19 2010
+######################################################################
+
+TEMPLATE = app
+TARGET = 
+DEPENDPATH += . ../
+INCLUDEPATH += . ../
+LIBS += -L../ -lkeduvocdocument
+QT += core testlib
+CONFIG +=qtestlib
+
+# Input
+SOURCES += tests.cpp