LCOV - code coverage report
Current view: top level - editeng/qa/unit - core-test.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 231 248 93.1 %
Date: 2014-04-11 Functions: 26 31 83.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include "test/bootstrapfixture.hxx"
      11             : 
      12             : #include <cppunit/TestFixture.h>
      13             : #include <cppunit/extensions/HelperMacros.h>
      14             : 
      15             : #include "svl/itempool.hxx"
      16             : #include "editeng/eerdll.hxx"
      17             : #include "editeng/eerdll2.hxx"
      18             : #include "editeng/editeng.hxx"
      19             : #include "editeng/eeitem.hxx"
      20             : #include "editeng/editids.hrc"
      21             : #include "editeng/editdoc.hxx"
      22             : #include "editeng/svxacorr.hxx"
      23             : #include "editeng/unofield.hxx"
      24             : #include "editeng/wghtitem.hxx"
      25             : #include "editeng/postitem.hxx"
      26             : #include "editeng/section.hxx"
      27             : #include "editeng/editobj.hxx"
      28             : 
      29             : #include <com/sun/star/text/textfield/Type.hpp>
      30             : 
      31             : #include <boost/scoped_ptr.hpp>
      32             : 
      33             : using namespace com::sun::star;
      34             : 
      35             : namespace {
      36             : 
      37           8 : class Test : public test::BootstrapFixture
      38             : {
      39             : public:
      40             :     Test();
      41             : 
      42             :     virtual void setUp() SAL_OVERRIDE;
      43             :     virtual void tearDown() SAL_OVERRIDE;
      44             : 
      45             :     void testConstruction();
      46             : 
      47             :     /**
      48             :      * Test UNO service class that implements text field items.
      49             :      */
      50             :     void testUnoTextFields();
      51             : 
      52             :     /**
      53             :      * AutoCorrect tests
      54             :      */
      55             :     void testAutocorrect();
      56             : 
      57             :     void testSectionAttributes();
      58             : 
      59           2 :     CPPUNIT_TEST_SUITE(Test);
      60           1 :     CPPUNIT_TEST(testConstruction);
      61           1 :     CPPUNIT_TEST(testUnoTextFields);
      62           1 :     CPPUNIT_TEST(testAutocorrect);
      63           1 :     CPPUNIT_TEST(testSectionAttributes);
      64           2 :     CPPUNIT_TEST_SUITE_END();
      65             : 
      66             : private:
      67             :     EditEngineItemPool* mpItemPool;
      68             : };
      69             : 
      70           4 : Test::Test() : mpItemPool(NULL) {}
      71             : 
      72           4 : void Test::setUp()
      73             : {
      74           4 :     test::BootstrapFixture::setUp();
      75             : 
      76           4 :     mpItemPool = new EditEngineItemPool(true);
      77           4 : }
      78             : 
      79           4 : void Test::tearDown()
      80             : {
      81           4 :     SfxItemPool::Free(mpItemPool);
      82           4 :     test::BootstrapFixture::tearDown();
      83           4 : }
      84             : 
      85           1 : void Test::testConstruction()
      86             : {
      87           1 :     EditEngine aEngine(mpItemPool);
      88             : 
      89           2 :     OUString aParaText = "I am Edit Engine.";
      90           2 :     aEngine.SetText(aParaText);
      91           1 : }
      92             : 
      93             : namespace {
      94             : 
      95          14 : bool includes(const uno::Sequence<OUString>& rSeq, const OUString& rVal)
      96             : {
      97          56 :     for (sal_Int32 i = 0, n = rSeq.getLength(); i < n; ++i)
      98          56 :         if (rSeq[i] == rVal)
      99          14 :             return true;
     100             : 
     101           0 :     return false;
     102             : }
     103             : 
     104             : }
     105             : 
     106           1 : void Test::testUnoTextFields()
     107             : {
     108             :     {
     109             :         // DATE
     110           1 :         SvxUnoTextField aField(text::textfield::Type::DATE);
     111           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     112           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
     113           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     114             :     }
     115             : 
     116             :     {
     117             :         // URL
     118           1 :         SvxUnoTextField aField(text::textfield::Type::URL);
     119           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     120           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.URL");
     121           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     122             :     }
     123             : 
     124             :     {
     125             :         // PAGE
     126           1 :         SvxUnoTextField aField(text::textfield::Type::PAGE);
     127           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     128           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageNumber");
     129           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     130             :     }
     131             : 
     132             :     {
     133             :         // PAGES
     134           1 :         SvxUnoTextField aField(text::textfield::Type::PAGES);
     135           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     136           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageCount");
     137           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     138             :     }
     139             : 
     140             :     {
     141             :         // TIME
     142           1 :         SvxUnoTextField aField(text::textfield::Type::TIME);
     143           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     144           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
     145           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     146             :     }
     147             : 
     148             :     {
     149             :         // FILE
     150           1 :         SvxUnoTextField aField(text::textfield::Type::DOCINFO_TITLE);
     151           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     152           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.docinfo.Title");
     153           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     154             :     }
     155             : 
     156             :     {
     157             :         // TABLE
     158           1 :         SvxUnoTextField aField(text::textfield::Type::TABLE);
     159           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     160           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.SheetName");
     161           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     162             :     }
     163             : 
     164             :     {
     165             :         // EXTENDED TIME
     166           1 :         SvxUnoTextField aField(text::textfield::Type::EXTENDED_TIME);
     167           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     168           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
     169           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     170             :     }
     171             : 
     172             :     {
     173             :         // EXTENDED FILE
     174           1 :         SvxUnoTextField aField(text::textfield::Type::EXTENDED_FILE);
     175           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     176           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.FileName");
     177           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     178             :     }
     179             : 
     180             :     {
     181             :         // AUTHOR
     182           1 :         SvxUnoTextField aField(text::textfield::Type::AUTHOR);
     183           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     184           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Author");
     185           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     186             :     }
     187             : 
     188             :     {
     189             :         // MEASURE
     190           1 :         SvxUnoTextField aField(text::textfield::Type::MEASURE);
     191           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     192           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Measure");
     193           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     194             :     }
     195             : 
     196             :     {
     197             :         // PRESENTATION HEADER
     198           1 :         SvxUnoTextField aField(text::textfield::Type::PRESENTATION_HEADER);
     199           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     200           1 :         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Header");
     201           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     202             :     }
     203             : 
     204             :     {
     205             :         // PRESENTATION FOOTER
     206           1 :         SvxUnoTextField aField(text::textfield::Type::PRESENTATION_FOOTER);
     207           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     208           1 :         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Footer");
     209           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     210             :     }
     211             : 
     212             :     {
     213             :         // PRESENTATION DATE TIME
     214           1 :         SvxUnoTextField aField(text::textfield::Type::PRESENTATION_DATE_TIME);
     215           2 :         uno::Sequence<OUString> aSvcs = aField.getSupportedServiceNames();
     216           1 :         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.DateTime");
     217           2 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     218             :     }
     219           1 : }
     220             : 
     221           3 : class TestAutoCorrDoc : public SvxAutoCorrDoc
     222             : {
     223             : public:
     224             :     /// just like the real thing, this dummy modifies the rText parameter :(
     225           3 :     TestAutoCorrDoc(OUString &rText, LanguageType eLang)
     226             :         : m_rText(rText)
     227           3 :         , m_eLang(eLang)
     228             :     {
     229           3 :     }
     230           3 :     OUString const& getResult() const
     231             :     {
     232           3 :         return m_rText;
     233             :     }
     234             : private:
     235             :     OUString & m_rText;
     236             :     LanguageType m_eLang;
     237           2 :     virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) SAL_OVERRIDE
     238             :     {
     239             :         //fprintf(stderr, "TestAutoCorrDoc::Delete\n");
     240           2 :         m_rText = m_rText.replaceAt(nStt, nEnd-nStt, "");
     241           2 :         return true;
     242             :     }
     243           3 :     virtual bool Insert( sal_Int32 nPos, const OUString& rTxt ) SAL_OVERRIDE
     244             :     {
     245             :         //fprintf(stderr, "TestAutoCorrDoc::Insert\n");
     246           3 :         m_rText = m_rText.replaceAt(nPos, 0, rTxt);
     247           3 :         return true;
     248             :     }
     249           0 :     virtual bool Replace( sal_Int32 nPos, const OUString& rTxt ) SAL_OVERRIDE
     250             :     {
     251             :         //fprintf(stderr, "TestAutoCorrDoc::Replace\n");
     252           0 :         return ReplaceRange( nPos, rTxt.getLength(), rTxt );
     253             :     }
     254           4 :     virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rTxt ) SAL_OVERRIDE
     255             :     {
     256             :         //fprintf(stderr, "TestAutoCorrDoc::ReplaceRange %d %d %s\n", nPos, nLen, OUStringToOString(rTxt, RTL_TEXTENCODING_UTF8).getStr());
     257           4 :         m_rText = m_rText.replaceAt(nPos, nLen, rTxt);
     258           4 :         return true;
     259             :     }
     260           1 :     virtual bool SetAttr( sal_Int32, sal_Int32, sal_uInt16, SfxPoolItem& ) SAL_OVERRIDE
     261             :     {
     262             :         //fprintf(stderr, "TestAutoCorrDoc::SetAttr\n");
     263           1 :         return true;
     264             :     }
     265           0 :     virtual bool SetINetAttr( sal_Int32, sal_Int32, const OUString& ) SAL_OVERRIDE
     266             :     {
     267             :         //fprintf(stderr, "TestAutoCorrDoc::SetINetAttr\n");
     268           0 :         return true;
     269             :     }
     270           0 :     virtual OUString const* GetPrevPara(bool) SAL_OVERRIDE
     271             :     {
     272             :         //fprintf(stderr, "TestAutoCorrDoc::GetPrevPara\n");
     273           0 :         return 0;
     274             :     }
     275           2 :     virtual bool ChgAutoCorrWord( sal_Int32& rSttPos,
     276             :                 sal_Int32 nEndPos, SvxAutoCorrect& rACorrect,
     277             :                 OUString* pPara ) SAL_OVERRIDE
     278             :     {
     279             :         //fprintf(stderr, "TestAutoCorrDoc::ChgAutoCorrWord\n");
     280             : 
     281           2 :         if (m_rText.isEmpty())
     282           0 :             return false;
     283             : 
     284           2 :         LanguageTag aLanguageTag( m_eLang);
     285             :         const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList(
     286           2 :                 m_rText, rSttPos, nEndPos, *this, aLanguageTag);
     287           2 :         if (pFnd && pFnd->IsTextOnly())
     288             :         {
     289           0 :             m_rText = m_rText.replaceAt(rSttPos, nEndPos, pFnd->GetLong());
     290           0 :             if( pPara )
     291           0 :                 *pPara = "";//&pCurNode->GetString();
     292           0 :             return true;
     293             :         }
     294             : 
     295           2 :         return false;
     296             :     }
     297             : };
     298             : 
     299             : //https://bugs.libreoffice.org/show_bug.cgi?id=55693
     300             : //Two capitalized letters are not corrected if dash or slash are directly
     301             : //before the two letters
     302           1 : void Test::testAutocorrect()
     303             : {
     304           1 :     OUString sShareAutocorrFile;
     305           2 :     OUString sUserAutocorrFile;
     306           2 :     SvxAutoCorrect aAutoCorrect(sShareAutocorrFile, sUserAutocorrFile);
     307             : 
     308             :     {
     309           1 :         OUString sInput("TEst-TEst");
     310           1 :         sal_Unicode cNextChar(' ');
     311           2 :         OUString sExpected("Test-Test ");
     312             : 
     313           2 :         TestAutoCorrDoc aFoo(sInput, LANGUAGE_ENGLISH_US);
     314           1 :         aAutoCorrect.DoAutoCorrect(aFoo, sInput, sInput.getLength(), cNextChar, true);
     315             : 
     316           2 :         CPPUNIT_ASSERT_MESSAGE("autocorrect", aFoo.getResult() == sExpected);
     317             :     }
     318             : 
     319             :     {
     320           1 :         OUString sInput("TEst/TEst");
     321           1 :         sal_Unicode cNextChar(' ');
     322           2 :         OUString sExpected("Test/Test ");
     323             : 
     324           2 :         TestAutoCorrDoc aFoo(sInput, LANGUAGE_ENGLISH_US);
     325           1 :         aAutoCorrect.DoAutoCorrect(aFoo, sInput, sInput.getLength(), cNextChar, true);
     326             : 
     327           2 :         CPPUNIT_ASSERT_MESSAGE("autocorrect", aFoo.getResult() == sExpected);
     328             :     }
     329             : 
     330             :     {
     331             :         // test auto-bolding with '*'
     332           1 :         OUString sInput("*foo");
     333           1 :         sal_Unicode cNextChar('*');
     334           2 :         OUString sExpected("foo");
     335             : 
     336           2 :         TestAutoCorrDoc aFoo(sInput, LANGUAGE_ENGLISH_US);
     337           1 :         aAutoCorrect.DoAutoCorrect(aFoo, sInput, sInput.getLength(), cNextChar, true);
     338             : 
     339           2 :         CPPUNIT_ASSERT_EQUAL(sExpected, aFoo.getResult());
     340           1 :     }
     341           1 : }
     342             : 
     343           5 : bool hasBold(const editeng::Section& rSecAttr)
     344             : {
     345           5 :     std::vector<const SfxPoolItem*>::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end();
     346           5 :     for (; it != itEnd; ++it)
     347             :     {
     348           5 :         const SfxPoolItem* p = *it;
     349           5 :         if (p->Which() != EE_CHAR_WEIGHT)
     350           0 :             continue;
     351             : 
     352           5 :         if (static_cast<const SvxWeightItem*>(p)->GetWeight() != WEIGHT_BOLD)
     353           0 :             continue;
     354             : 
     355           5 :         return true;
     356             :     }
     357           0 :     return false;
     358             : }
     359             : 
     360           2 : bool hasItalic(const editeng::Section& rSecAttr)
     361             : {
     362           2 :     std::vector<const SfxPoolItem*>::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end();
     363           3 :     for (; it != itEnd; ++it)
     364             :     {
     365           3 :         const SfxPoolItem* p = *it;
     366           3 :         if (p->Which() != EE_CHAR_ITALIC)
     367           1 :             continue;
     368             : 
     369           2 :         if (static_cast<const SvxPostureItem*>(p)->GetPosture() != ITALIC_NORMAL)
     370           0 :             continue;
     371             : 
     372           2 :         return true;
     373             :     }
     374           0 :     return false;
     375             : }
     376             : 
     377           1 : void Test::testSectionAttributes()
     378             : {
     379           1 :     EditEngine aEngine(mpItemPool);
     380             : 
     381           2 :     boost::scoped_ptr<SfxItemSet> pSet(new SfxItemSet(aEngine.GetEmptyItemSet()));
     382           2 :     SvxWeightItem aBold(WEIGHT_BOLD, EE_CHAR_WEIGHT);
     383           2 :     SvxPostureItem aItalic(ITALIC_NORMAL, EE_CHAR_ITALIC);
     384             : 
     385             :     {
     386           1 :         OUString aParaText = "aaabbbccc";
     387           1 :         aEngine.SetText(aParaText);
     388           1 :         pSet->Put(aBold);
     389           1 :         CPPUNIT_ASSERT_MESSAGE("There should be exactly one item.", pSet->Count() == 1);
     390           1 :         aEngine.QuickSetAttribs(*pSet, ESelection(0,0,0,6)); // 'aaabbb' - end point is not inclusive.
     391           1 :         pSet.reset(new SfxItemSet(aEngine.GetEmptyItemSet()));
     392           1 :         pSet->Put(aItalic);
     393           1 :         CPPUNIT_ASSERT_MESSAGE("There should be exactly one item.", pSet->Count() == 1);
     394             : 
     395           1 :         aEngine.QuickSetAttribs(*pSet, ESelection(0,3,0,9)); // 'bbbccc'
     396           2 :         boost::scoped_ptr<EditTextObject> pEditText(aEngine.CreateTextObject());
     397           1 :         CPPUNIT_ASSERT_MESSAGE("Failed to create text object.", pEditText.get());
     398           2 :         std::vector<editeng::Section> aAttrs;
     399           1 :         pEditText->GetAllSections(aAttrs);
     400             : 
     401             :         // Now, we should have a total of 3 sections.
     402           1 :         CPPUNIT_ASSERT_MESSAGE("There should be 3 sections.", aAttrs.size() == 3);
     403             : 
     404             :         // First section should be 0-3 of paragraph 0, and it should only have boldness applied.
     405           1 :         const editeng::Section* pSecAttr = &aAttrs[0];
     406           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnParagraph);
     407           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
     408           1 :         CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnEnd);
     409           1 :         CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
     410           1 :         CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(*pSecAttr));
     411             : 
     412             :         // Second section should be 3-6, and it should be both bold and italic.
     413           1 :         pSecAttr = &aAttrs[1];
     414           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnParagraph);
     415           1 :         CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnStart);
     416           1 :         CPPUNIT_ASSERT_EQUAL(6, (int)pSecAttr->mnEnd);
     417           1 :         CPPUNIT_ASSERT_EQUAL(2, (int)pSecAttr->maAttributes.size());
     418           1 :         CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(*pSecAttr) && hasItalic(*pSecAttr));
     419             : 
     420             :         // Third section should be 6-9, and it should be only italic.
     421           1 :         pSecAttr = &aAttrs[2];
     422           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnParagraph);
     423           1 :         CPPUNIT_ASSERT_EQUAL(6, (int)pSecAttr->mnStart);
     424           1 :         CPPUNIT_ASSERT_EQUAL(9, (int)pSecAttr->mnEnd);
     425           1 :         CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
     426           2 :         CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(*pSecAttr));
     427             :     }
     428             : 
     429             :     {
     430             :         // Set text consisting of 5 paragraphs with the 2nd and 4th paragraphs
     431             :         // being empty.
     432           1 :         aEngine.Clear();
     433           1 :         aEngine.SetText("one\n\ntwo\n\nthree");
     434           1 :         sal_Int32 nParaCount = aEngine.GetParagraphCount();
     435           1 :         sal_Int32 nCheck = 5;
     436           1 :         CPPUNIT_ASSERT_EQUAL(nCheck, nParaCount);
     437             : 
     438             :         // Apply boldness to paragraphs 1, 3, 5 only. Leave 2 and 4 unformatted.
     439           1 :         pSet.reset(new SfxItemSet(aEngine.GetEmptyItemSet()));
     440           1 :         pSet->Put(aBold);
     441           1 :         CPPUNIT_ASSERT_MESSAGE("There should be exactly one item.", pSet->Count() == 1);
     442           1 :         aEngine.QuickSetAttribs(*pSet, ESelection(0,0,0,3));
     443           1 :         aEngine.QuickSetAttribs(*pSet, ESelection(2,0,2,3));
     444           1 :         aEngine.QuickSetAttribs(*pSet, ESelection(4,0,4,5));
     445             : 
     446           1 :         boost::scoped_ptr<EditTextObject> pEditText(aEngine.CreateTextObject());
     447           1 :         CPPUNIT_ASSERT_MESSAGE("Failed to create text object.", pEditText.get());
     448           2 :         std::vector<editeng::Section> aAttrs;
     449           1 :         pEditText->GetAllSections(aAttrs);
     450           1 :         size_t nSecCountCheck = 5;
     451           1 :         CPPUNIT_ASSERT_EQUAL(nSecCountCheck, aAttrs.size());
     452             : 
     453             :         // 1st, 3rd and 5th sections should correspond with 1st, 3rd and 5th paragraphs.
     454           1 :         const editeng::Section* pSecAttr = &aAttrs[0];
     455           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnParagraph);
     456           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
     457           1 :         CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnEnd);
     458           1 :         CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
     459           1 :         CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(*pSecAttr));
     460             : 
     461           1 :         pSecAttr = &aAttrs[2];
     462           1 :         CPPUNIT_ASSERT_EQUAL(2, (int)pSecAttr->mnParagraph);
     463           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
     464           1 :         CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnEnd);
     465           1 :         CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
     466           1 :         CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(*pSecAttr));
     467             : 
     468           1 :         pSecAttr = &aAttrs[4];
     469           1 :         CPPUNIT_ASSERT_EQUAL(4, (int)pSecAttr->mnParagraph);
     470           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
     471           1 :         CPPUNIT_ASSERT_EQUAL(5, (int)pSecAttr->mnEnd);
     472           1 :         CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
     473           1 :         CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(*pSecAttr));
     474             : 
     475             :         // The 2nd and 4th paragraphs should be empty.
     476           1 :         pSecAttr = &aAttrs[1];
     477           1 :         CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->mnParagraph);
     478           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
     479           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnEnd);
     480           1 :         CPPUNIT_ASSERT_MESSAGE("Attribute array should be empty.", pSecAttr->maAttributes.empty());
     481             : 
     482           1 :         pSecAttr = &aAttrs[3];
     483           1 :         CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnParagraph);
     484           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
     485           1 :         CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnEnd);
     486           2 :         CPPUNIT_ASSERT_MESSAGE("Attribute array should be empty.", pSecAttr->maAttributes.empty());
     487           1 :     }
     488           1 : }
     489             : 
     490           1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
     491             : 
     492             : }
     493             : 
     494           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     495             : 
     496             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10