Kaydet (Commit) 7483d11c authored tarafından Caolán McNamara's avatar Caolán McNamara

add a regression test to confirm SwDocStat works the way I think

üst 1640c883
......@@ -55,6 +55,7 @@
#include "init.hxx"
#include "swtypes.hxx"
#include "docstat.hxx"
#include "doc.hxx"
#include "docsh.hxx"
#include "shellres.hxx"
......@@ -81,11 +82,13 @@ public:
void randomTest();
void testPageDescName();
void testFileNameFields();
void testDocStat();
CPPUNIT_TEST_SUITE(SwDocTest);
CPPUNIT_TEST(randomTest);
CPPUNIT_TEST(testPageDescName);
CPPUNIT_TEST(testFileNameFields);
CPPUNIT_TEST(testDocStat);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -172,6 +175,28 @@ void SwDocTest::testFileNameFields()
m_xDocShRef->DoInitNew(0);
}
void SwDocTest::testDocStat()
{
CPPUNIT_ASSERT_MESSAGE("Expected initial 0 count", m_pDoc->GetDocStat().nChar == 0);
SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1);
SwPaM aPaM(aIdx);
rtl::OUString sText(RTL_CONSTASCII_USTRINGPARAM("Hello World"));
m_pDoc->InsertString(aPaM, sText);
CPPUNIT_ASSERT_MESSAGE("Should still be non-updated 0 count", m_pDoc->GetDocStat().nChar == 0);
SwDocStat aDocStat = m_pDoc->GetDocStat();
m_pDoc->UpdateDocStat(aDocStat);
sal_uLong nLen = static_cast<sal_uLong>(sText.getLength());
CPPUNIT_ASSERT_MESSAGE("Should now have updated count", aDocStat.nChar == nLen);
CPPUNIT_ASSERT_MESSAGE("And cache is updated too", m_pDoc->GetDocStat().nChar == nLen);
}
static int
getRand(int modulus)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment