]> Git trees. - libqmvoc.git/commitdiff
unit test to make sure language deletion works as expected
authorFrederik Gladhorn <gladhorn@kde.org>
Fri, 15 Aug 2008 12:22:06 +0000 (12:22 +0000)
committerFrederik Gladhorn <gladhorn@kde.org>
Fri, 15 Aug 2008 12:22:06 +0000 (12:22 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=847452

keduvocdocument/tests/keduvocdocumentvalidatortest.cpp

index 9299f8e0cb0b40177c03caa7bfc533690d335baa..acf3f782fdda181fd182b4e8d6a4e69185e25063 100644 (file)
@@ -46,6 +46,8 @@ private slots:
     void testTranslations();
     void testConjugations();
     void testDeclensions();
+    void testAddRemoveLanguage();
+
 };
 
 void KEduVocDocumentValidatorTest::testDocumentAboutInfo()
@@ -207,6 +209,44 @@ void KEduVocDocumentValidatorTest::testConjugations()
     delete con2;
 }
 
+void KEduVocDocumentValidatorTest::testAddRemoveLanguage()
+{
+    KEduVocDocument doc;
+    // create some initial languages
+    doc.appendIdentifier();
+    doc.appendIdentifier();
+    doc.appendIdentifier();
+    doc.appendIdentifier();
+    doc.identifier(0).setName("0");
+    doc.identifier(1).setName("1");
+    doc.identifier(2).setName("2");
+    doc.identifier(3).setName("3");
+
+    QCOMPARE(doc.identifierCount(), 4);
+    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");
+    lesson->entry(0)->setTranslation(2, "2");
+    lesson->entry(0)->setTranslation(3, "3");
+    QCOMPARE(lesson->entry(0)->translationIndices().size(), 4);
+
+    // throw away the second language
+    doc.removeIdentifier(1);
+
+    QCOMPARE(doc.identifierCount(), 3);
+    QCOMPARE(doc.identifier(0).name(), QString("0"));
+    QCOMPARE(doc.identifier(1).name(), QString("2"));
+    QCOMPARE(doc.identifier(2).name(), QString("3"));
+
+    QCOMPARE(lesson->entry(0)->translationIndices().size(), 3);
+    QCOMPARE(lesson->entry(0)->translation(0)->text(), QString("0"));
+    QCOMPARE(lesson->entry(0)->translation(1)->text(), QString("2"));
+    QCOMPARE(lesson->entry(0)->translation(2)->text(), QString("3"));
+}
+
+
 QTEST_KDEMAIN_CORE( KEduVocDocumentValidatorTest )
 
 #include "keduvocdocumentvalidatortest.moc"