[Libreoffice-commits] core.git: Branch 'private/kohei/calc-shared-string' - 3 commits - sc/qa sc/source svl/qa svl/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Oct 11 08:31:47 PDT 2013


 sc/qa/unit/subsequent_filters-test.cxx |   37 +++++++++++++++++++++------------
 sc/source/ui/view/gridwin.cxx          |    2 -
 svl/qa/unit/svl.cxx                    |   24 ++++++++++++++++-----
 svl/source/misc/sharedstring.cxx       |    2 -
 4 files changed, 44 insertions(+), 21 deletions(-)

New commits:
commit 9890d623906cbcc49b3491edf10085be9a99743c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Oct 11 11:33:05 2013 -0400

    Fix equality operator for SharedString & write test for it.
    
    Change-Id: Ib592ca2fe359293da6c10aa9e1535a91627cfc43

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 0ac019b..a34150f 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -39,6 +39,7 @@
 #include <boost/scoped_ptr.hpp>
 
 using namespace ::com::sun::star;
+using namespace svl;
 
 namespace {
 
@@ -51,15 +52,17 @@ public:
     virtual void tearDown();
 
     void testNumberFormat();
-    void testStringPool();
-    void testStringPoolPurge();
+    void testSharedString();
+    void testSharedStringPool();
+    void testSharedStringPoolPurge();
     void testFdo60915();
     void testI116701();
 
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testNumberFormat);
-    CPPUNIT_TEST(testStringPool);
-    CPPUNIT_TEST(testStringPoolPurge);
+    CPPUNIT_TEST(testSharedString);
+    CPPUNIT_TEST(testSharedStringPool);
+    CPPUNIT_TEST(testSharedStringPoolPurge);
     CPPUNIT_TEST(testFdo60915);
     CPPUNIT_TEST(testI116701);
     CPPUNIT_TEST_SUITE_END();
@@ -278,7 +281,16 @@ void Test::testNumberFormat()
     }
 }
 
-void Test::testStringPool()
+void Test::testSharedString()
+{
+    // Use shared string as normal, non-shared string, which is allowed.
+    SharedString aSS1("Test"), aSS2("Test");
+    CPPUNIT_ASSERT_MESSAGE("Equality check should return true.", aSS1 == aSS2);
+    SharedString aSS3("test");
+    CPPUNIT_ASSERT_MESSAGE("Equality check is case sensitive.", aSS1 != aSS3);
+}
+
+void Test::testSharedStringPool()
 {
     SvtSysLocale aSysLocale;
     svl::SharedStringPool aPool(aSysLocale.GetCharClassPtr());
@@ -311,7 +323,7 @@ void Test::testStringPool()
     CPPUNIT_ASSERT_MESSAGE("These two ID's should be equal.", p1.getDataIgnoreCase() == p2.getDataIgnoreCase());
 }
 
-void Test::testStringPoolPurge()
+void Test::testSharedStringPoolPurge()
 {
     SvtSysLocale aSysLocale;
     svl::SharedStringPool aPool(aSysLocale.GetCharClassPtr());
diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx
index 8389ff8..6a5d395 100644
--- a/svl/source/misc/sharedstring.cxx
+++ b/svl/source/misc/sharedstring.cxx
@@ -81,7 +81,7 @@ bool SharedString::operator== ( const SharedString& r ) const
         if (mpData->length != r.mpData->length)
             return false;
 
-        return rtl_ustr_compare_WithLength(mpData->buffer, mpData->length, r.mpData->buffer, r.mpData->length);
+        return rtl_ustr_reverseCompare_WithLength(mpData->buffer, mpData->length, r.mpData->buffer, r.mpData->length) == 0;
     }
 
     return !r.mpData;
commit 7a7a60361df09f713a0b574f0f054d256e4a4146
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Oct 11 11:23:54 2013 -0400

    Use OUString & a bit more fine-grained unit test error messages.
    
    Change-Id: I6d9ce2afd97d6011eaa93855c49f3d7071db0159

diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index b69cb08..5c0fb54 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -1046,16 +1046,18 @@ struct ValDataTestParams
 {
     ScValidationMode eValMode;
     ScConditionMode eCondOp;
-    String aStrVal1, aStrVal2;
+    OUString aStrVal1;
+    OUString aStrVal2;
     ScDocument* pDocument;
     ScAddress aPosition;
-    String aErrorTitle, aErrorMessage;
+    OUString aErrorTitle;
+    OUString aErrorMessage;
     ScValidErrorStyle eErrorStyle;
     sal_uLong nExpectedIndex;
 
     ValDataTestParams( ScValidationMode eMode, ScConditionMode eOp,
-                       String aExpr1, String aExpr2, ScDocument* pDoc,
-                       ScAddress aPos, String aETitle, String aEMsg,
+                       OUString aExpr1, OUString aExpr2, ScDocument* pDoc,
+                       ScAddress aPos, OUString aETitle, OUString aEMsg,
                        ScValidErrorStyle eEStyle, sal_uLong nIndex ):
                             eValMode(eMode), eCondOp(eOp), aStrVal1(aExpr1),
                             aStrVal2(aExpr2), pDocument(pDoc), aPosition(aPos),
@@ -1077,7 +1079,7 @@ void checkValiditationEntries( const ValDataTestParams& rVDTParams )
     aValData.SetListType( 1 );
     aValData.ResetInput();
     aValData.SetError( rVDTParams.aErrorTitle, rVDTParams.aErrorMessage, rVDTParams.eErrorStyle );
-    aValData.SetSrcString( EMPTY_STRING );
+    aValData.SetSrcString( EMPTY_OUSTRING );
 
     //get actual data validation entry from document
     const ScValidationData* pValDataTest = pDoc->GetValidationEntry( rVDTParams.nExpectedIndex );
@@ -1086,9 +1088,18 @@ void checkValiditationEntries( const ValDataTestParams& rVDTParams )
     sal_Int32 nRow( static_cast<sal_Int32>(rVDTParams.aPosition.Row()) );
     sal_Int32 nTab( static_cast<sal_Int32>(rVDTParams.aPosition.Tab()) );
     OStringBuffer sMsg("Data Validation Entry with base-cell-address: (");
-    sMsg.append(nCol).append(",").append(nRow).append(",").append(nTab).append(") was not imported correctly.");
+    sMsg.append(nCol).append(",").append(nRow).append(",").append(nTab).append(") ");
+    OString aMsgPrefix = sMsg.makeStringAndClear();
+
+    OString aMsg = aMsgPrefix + "did not get imported at all.";
+    CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), pValDataTest);
+
     //check if expected and actual data validation entries are equal
-    CPPUNIT_ASSERT_MESSAGE( sMsg.getStr(), pValDataTest && aValData.EqualEntries(*pValDataTest) );
+    if (!aValData.EqualEntries(*pValDataTest))
+    {
+        aMsg = aMsgPrefix + "got imported incorrectly.";
+        CPPUNIT_FAIL(aMsg.getStr());
+    }
 }
 
 void checkCellValidity( const ScAddress& rValBaseAddr, const ScRange& rRange, const ScDocument* pDoc )
@@ -1140,16 +1151,16 @@ void ScFiltersTest::testDataValidityODS()
 
     //sheet1's expected Data Validation Entry values
     ValDataTestParams aVDTParams1(
-        SC_VALID_DECIMAL, SC_COND_GREATER, String("3.14"), EMPTY_STRING, pDoc,
-        aValBaseAddr1, String("Too small"),
-        String("The number you are trying to enter is not greater than 3.14! Are you sure you want to enter it anyway?"),
+        SC_VALID_DECIMAL, SC_COND_GREATER, "3.14", EMPTY_OUSTRING, pDoc,
+        aValBaseAddr1, "Too small",
+        "The number you are trying to enter is not greater than 3.14! Are you sure you want to enter it anyway?",
         SC_VALERR_WARNING, 1
     );
     //sheet2's expected Data Validation Entry values
     ValDataTestParams aVDTParams2(
-        SC_VALID_WHOLE, SC_COND_BETWEEN, String("1"), String("10"), pDoc,
-        aValBaseAddr2, String("Error sheet 2"),
-        String("Must be a whole number between 1 and 10."),
+        SC_VALID_WHOLE, SC_COND_BETWEEN, "1", "10", pDoc,
+        aValBaseAddr2, "Error sheet 2",
+        "Must be a whole number between 1 and 10.",
         SC_VALERR_STOP, 2
     );
     //check each sheet's Data Validation Entries
commit 7902f2e81551065024d897378b4a91fb3f98d461
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Oct 10 23:23:55 2013 -0400

    Spell check context can be NULL (when the live spell check is not on).
    
    Change-Id: I785f83b5c2c6329b7a18af9f9721c06894207ea5

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9ef4359..d4d88e4 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -2979,7 +2979,7 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
 
         sal_Bool bDone = false;
         sal_Bool bEdit = pViewData->HasEditView(eWhich);
-        bool bSpellError = mpSpellCheckCxt->isMisspelled(nCellX, nCellY);
+        bool bSpellError = (mpSpellCheckCxt && mpSpellCheckCxt->isMisspelled(nCellX, nCellY));
 
         if ( !bEdit )
         {


More information about the Libreoffice-commits mailing list