sc/inc/refdata.hxx | 3 +++ sc/qa/unit/helper/qahelper.hxx | 3 +++ sc/qa/unit/ucalc.hxx | 3 +++ sc/qa/unit/ucalc_formula.cxx | 20 ++++++++++++++++++++ sc/source/core/tool/refdata.cxx | 21 +++++++++++++++++++++ 5 files changed, 50 insertions(+)
New commits: commit 6042ab0df406c8215d7b674241fd835406a6e678 Author: Kohei Yoshida <[email protected]> Date: Mon Jul 15 23:43:35 2013 -0400 Add some basic test for single reference data. I'll add more later. Change-Id: Ia65f29886c36fc268e4e8aa77e09b03628c5dccf diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 9c1594e..7eb4d45 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -162,6 +162,9 @@ public: #define ASSERT_DOUBLES_EQUAL_MESSAGE( message, expected, result ) \ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( (message), (expected), (result), 1e-14 ) +#define ASSERT_EQUAL_TYPE( type, expected, result ) \ + CPPUNIT_ASSERT_EQUAL( static_cast<type>(expected), static_cast<type>(result) ); + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 0f0198c..7582e63 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -82,7 +82,9 @@ public: void testCollator(); void testRangeList(); void testInput(); + void testFormulaHashAndTag(); + void testFormulaRefData(); void testFormulaCompiler(); void testFuncSUM(); void testFuncPRODUCT(); @@ -268,6 +270,7 @@ public: CPPUNIT_TEST(testRangeList); CPPUNIT_TEST(testInput); CPPUNIT_TEST(testFormulaHashAndTag); + CPPUNIT_TEST(testFormulaRefData); CPPUNIT_TEST(testFormulaCompiler); CPPUNIT_TEST(testFuncSUM); CPPUNIT_TEST(testFuncPRODUCT); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 7b029de..352259f 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -13,6 +13,7 @@ #include "interpre.hxx" #include "compiler.hxx" #include "tokenarray.hxx" +#include "refdata.hxx" #include <boost/scoped_ptr.hpp> @@ -109,6 +110,25 @@ void Test::testFormulaHashAndTag() m_pDoc->DeleteTab(0); } +void Test::testFormulaRefData() +{ + ScAddress aAddr(4,5,3), aPos(2,2,2); + ScSingleRefData aRefData; + aRefData.InitAddress(aAddr); + CPPUNIT_ASSERT_MESSAGE("Wrong ref data state.", !aRefData.IsRowRel() && !aRefData.IsColRel() && !aRefData.IsTabRel()); + ASSERT_EQUAL_TYPE(SCCOL, 4, aRefData.GetCol()); + ASSERT_EQUAL_TYPE(SCROW, 5, aRefData.GetRow()); + ASSERT_EQUAL_TYPE(SCTAB, 3, aRefData.GetTab()); + + aRefData.SetRowRel(true); + aRefData.SetColRel(true); + aRefData.SetTabRel(true); + aRefData.SetAddress(aAddr, aPos); + ASSERT_EQUAL_TYPE(SCCOL, 2, aRefData.GetCol()); + ASSERT_EQUAL_TYPE(SCROW, 3, aRefData.GetRow()); + ASSERT_EQUAL_TYPE(SCTAB, 1, aRefData.GetTab()); +} + void Test::testFormulaCompiler() { struct { commit 92226e98b0d6ccb11a7896489ff67a86088082c8 Author: Kohei Yoshida <[email protected]> Date: Mon Jul 15 23:43:02 2013 -0400 Add methods to avoid accessing data members directly. Change-Id: I7285a267e4e77e95c8d9bdfc5bad807111ead909 diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx index d79590c..d619f4f 100644 --- a/sc/inc/refdata.hxx +++ b/sc/inc/refdata.hxx @@ -83,6 +83,9 @@ struct SC_DLLPUBLIC ScSingleRefData ScAddress toAbs( const ScAddress& rPos ) const; void SetAddress( const ScAddress& rAddr, const ScAddress& rPos ); + SCROW GetRow() const; + SCCOL GetCol() const; + SCTAB GetTab() const; void CalcRelFromAbs( const ScAddress& rPos ); void CalcAbsIfRel( const ScAddress& rPos ); diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx index aaca903..9988b87 100644 --- a/sc/source/core/tool/refdata.cxx +++ b/sc/source/core/tool/refdata.cxx @@ -61,6 +61,27 @@ void ScSingleRefData::SetAddress( const ScAddress& rAddr, const ScAddress& rPos nTab = rAddr.Tab(); } +SCROW ScSingleRefData::GetRow() const +{ + if (Flags.bRowDeleted) + return -1; + return Flags.bRowRel ? nRelRow : nRow; +} + +SCCOL ScSingleRefData::GetCol() const +{ + if (Flags.bColDeleted) + return -1; + return Flags.bColRel ? nRelCol : nCol; +} + +SCTAB ScSingleRefData::GetTab() const +{ + if (Flags.bTabDeleted) + return -1; + return Flags.bTabRel ? nRelTab : nTab; +} + void ScSingleRefData::CalcAbsIfRel( const ScAddress& rPos ) { if ( Flags.bColRel ) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
