[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/libkdeedu/keduvocdocument/tests
From:       Frederik Gladhorn <frederik.gladhorn () gmx ! de>
Date:       2008-08-15 12:22:06
Message-ID: 1218802926.487074.21791.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 847452 by gladhorn:

unit test to make sure language deletion works as expected

 M  +40 -0     keduvocdocumentvalidatortest.cpp  


--- trunk/KDE/kdeedu/libkdeedu/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp #847451:847452
@@ -46,6 +46,8 @@
     void testTranslations();
     void testConjugations();
     void testDeclensions();
+    void testAddRemoveLanguage();
+
 };
 
 void KEduVocDocumentValidatorTest::testDocumentAboutInfo()
@@ -207,6 +209,44 @@
     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"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic