From 50cb0c496d71d644f4d427f48200d9b28eeefd04 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 15 Aug 2008 12:22:06 +0000 Subject: [PATCH] unit test to make sure language deletion works as expected svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=847452 --- .../tests/keduvocdocumentvalidatortest.cpp | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp b/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp index 9299f8e..acf3f78 100644 --- a/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp +++ b/keduvocdocument/tests/keduvocdocumentvalidatortest.cpp @@ -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" -- 2.47.3