[Libreoffice-commits] .: 3 commits - sc/qa sc/source
Caolán McNamara
caolan at kemper.freedesktop.org
Wed Dec 1 13:01:24 PST 2010
sc/qa/unit/ucalc.cxx | 60 ++++++++++++++++++++++++++++++----------
sc/source/ui/dbgui/pvlaydlg.cxx | 2 -
2 files changed, 46 insertions(+), 16 deletions(-)
New commits:
commit 5277dc2fececdf08b9a4d5843443596e35e906fc
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Dec 1 20:27:29 2010 +0000
cppunit: rearrange to get count of tests in output
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index a259379..5be5800 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -46,21 +46,20 @@ namespace {
class Test : public CppUnit::TestFixture {
public:
- // init
virtual void setUp();
virtual void tearDown();
- // tests
- void testDocument();
- void testSUM(ScDocument &rDoc);
- void testNamedRange(ScDocument &rDoc);
+ void testSUM();
+ void testNamedRange();
CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(testDocument);
+ CPPUNIT_TEST(testSUM);
+ CPPUNIT_TEST(testNamedRange);
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference< uno::XComponentContext > m_context;
+ ScDocument *m_pDoc;
};
void Test::setUp()
@@ -78,64 +77,59 @@ void Test::setUp()
InitVCL(xSM);
ScDLL::Init();
+
+ m_pDoc = new ScDocument;
}
void Test::tearDown()
{
+ delete m_pDoc;
uno::Reference< lang::XComponent >(m_context, uno::UNO_QUERY_THROW)->dispose();
}
-void Test::testSUM(ScDocument &rDoc)
+void Test::testSUM()
{
rtl::OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("foo"));
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
- rDoc.InsertTab (0, aTabName));
+ m_pDoc->InsertTab (0, aTabName));
double val = 1;
- rDoc.SetValue (0, 0, 0, val);
- rDoc.SetValue (0, 1, 0, val);
- rDoc.SetString (0, 2, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=SUM(A1:A2)")));
- rDoc.CalcAll();
+ m_pDoc->SetValue (0, 0, 0, val);
+ m_pDoc->SetValue (0, 1, 0, val);
+ m_pDoc->SetString (0, 2, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=SUM(A1:A2)")));
+ m_pDoc->CalcAll();
double result;
- rDoc.GetValue (0, 2, 0, result);
+ m_pDoc->GetValue (0, 2, 0, result);
CPPUNIT_ASSERT_MESSAGE ("calculation failed", result == 2.0);
- rDoc.DeleteTab(0);
+ m_pDoc->DeleteTab(0);
}
-void Test::testNamedRange(ScDocument &rDoc)
+void Test::testNamedRange()
{
rtl::OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("Sheet1"));
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
- rDoc.InsertTab (0, aTabName));
+ m_pDoc->InsertTab (0, aTabName));
- rDoc.SetValue (0, 0, 0, 101);
+ m_pDoc->SetValue (0, 0, 0, 101);
ScAddress aA1(0, 0, 0);
ScRangeName* pNewRanges = new ScRangeName();
- ScRangeData* pNew = new ScRangeData(&rDoc,
+ ScRangeData* pNew = new ScRangeData(m_pDoc,
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Divisor")),
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$A$1:$A$1048576")), aA1, 0, formula::FormulaGrammar::GRAM_PODF_A1);
bool bSuccess = pNewRanges->Insert(pNew);
CPPUNIT_ASSERT_MESSAGE ("insertion failed", bSuccess);
- rDoc.SetRangeName(pNewRanges);
+ m_pDoc->SetRangeName(pNewRanges);
- rDoc.SetString (1, 0, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=A1/Divisor")));
+ m_pDoc->SetString (1, 0, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=A1/Divisor")));
- rDoc.CalcAll();
+ m_pDoc->CalcAll();
double result;
- rDoc.GetValue (1, 0, 0, result);
+ m_pDoc->GetValue (1, 0, 0, result);
CPPUNIT_ASSERT_MESSAGE ("calculation failed", result == 1.0);
- rDoc.DeleteTab(0);
-}
-
-void Test::testDocument()
-{
- ScDocument aDoc;
-
- testSUM(aDoc);
- testNamedRange(aDoc);
+ m_pDoc->DeleteTab(0);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
commit 77eb7b412b66519584792d7f319c8c50fe3bc455
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Dec 1 20:21:38 2010 +0000
cppunit: add a simple NamedRange test
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index bd48571..a259379 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -51,10 +51,12 @@ public:
virtual void tearDown();
// tests
- void createDocument();
+ void testDocument();
+ void testSUM(ScDocument &rDoc);
+ void testNamedRange(ScDocument &rDoc);
CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(createDocument);
+ CPPUNIT_TEST(testDocument);
CPPUNIT_TEST_SUITE_END();
private:
@@ -83,23 +85,57 @@ void Test::tearDown()
uno::Reference< lang::XComponent >(m_context, uno::UNO_QUERY_THROW)->dispose();
}
-void Test::createDocument()
+void Test::testSUM(ScDocument &rDoc)
{
- ScDocument *doc = new ScDocument();
-
rtl::OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("foo"));
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
- doc->InsertTab (0, aTabName));
+ rDoc.InsertTab (0, aTabName));
double val = 1;
- doc->SetValue (0, 0, 0, val);
- doc->SetValue (0, 1, 0, val);
- doc->SetString (0, 2, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=SUM(A1:A2)")));
- doc->CalcAll();
+ rDoc.SetValue (0, 0, 0, val);
+ rDoc.SetValue (0, 1, 0, val);
+ rDoc.SetString (0, 2, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=SUM(A1:A2)")));
+ rDoc.CalcAll();
double result;
- doc->GetValue (0, 2, 0, result);
+ rDoc.GetValue (0, 2, 0, result);
CPPUNIT_ASSERT_MESSAGE ("calculation failed", result == 2.0);
-
- delete doc;
+
+ rDoc.DeleteTab(0);
+}
+
+void Test::testNamedRange(ScDocument &rDoc)
+{
+ rtl::OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("Sheet1"));
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ rDoc.InsertTab (0, aTabName));
+
+ rDoc.SetValue (0, 0, 0, 101);
+
+ ScAddress aA1(0, 0, 0);
+ ScRangeName* pNewRanges = new ScRangeName();
+ ScRangeData* pNew = new ScRangeData(&rDoc,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Divisor")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$A$1:$A$1048576")), aA1, 0, formula::FormulaGrammar::GRAM_PODF_A1);
+ bool bSuccess = pNewRanges->Insert(pNew);
+ CPPUNIT_ASSERT_MESSAGE ("insertion failed", bSuccess);
+
+ rDoc.SetRangeName(pNewRanges);
+
+ rDoc.SetString (1, 0, 0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=A1/Divisor")));
+
+ rDoc.CalcAll();
+ double result;
+ rDoc.GetValue (1, 0, 0, result);
+ CPPUNIT_ASSERT_MESSAGE ("calculation failed", result == 1.0);
+
+ rDoc.DeleteTab(0);
+}
+
+void Test::testDocument()
+{
+ ScDocument aDoc;
+
+ testSUM(aDoc);
+ testNamedRange(aDoc);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
commit be795152446b34ac313b2b53ab246833bf7ca76f
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Dec 1 15:37:03 2010 +0000
cppcheck: can reduce the scope of this variable
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 9757259..ab0172a 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -803,7 +803,6 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF
ScDPFieldWindow* theWnd = NULL;
ScDPFuncDataVec* theArr = NULL;
size_t nAt = 0;
- size_t nToIndex = 0;
Point aToPos;
BOOL bDataArr = FALSE;
@@ -840,6 +839,7 @@ void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPF
if ( Contains( theArr, fData.mnCol, nAt ) )
{
+ size_t nToIndex = 0;
aToPos = DlgPos2WndPos( rAtPos, *theWnd );
theWnd->GetExistingIndex( aToPos, nToIndex );
More information about the Libreoffice-commits
mailing list