[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - sc/qa sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu Oct 31 17:34:37 CET 2013


 sc/qa/unit/opencl-test.cxx      |    7 +++----
 sc/qa/unit/ucalc_formula.cxx    |   36 +++++++++++++++++++++++++++++++++++-
 sc/source/core/data/column2.cxx |    2 +-
 3 files changed, 39 insertions(+), 6 deletions(-)

New commits:
commit f762d1a344875691369aa33aec8a26973eb0a1e7
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Oct 31 12:35:30 2013 -0400

    Don't hard-code the start row position of string array to 0...
    
    Change-Id: I06724e2e8754ac20217f5375a445c85f9a5b31e6

diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 8e8424b..2418df7 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -239,13 +239,12 @@ void ScOpenclTest::testCompilerString()
     // Check the results of formula cells in the shared formula range.
     for (SCROW i = 1; i < 5; ++i)
     {
-#if 0
         double fLibre = pDoc->GetValue(ScAddress(2, i, 0));
         double fExcel = pDocRes->GetValue(ScAddress(2, i, 0));
         CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
-#endif
-        double fLibre = pDoc->GetValue(ScAddress(3, i, 0));
-        double fExcel = pDocRes->GetValue(ScAddress(3, i, 0));
+
+        fLibre = pDoc->GetValue(ScAddress(3, i, 0));
+        fExcel = pDocRes->GetValue(ScAddress(3, i, 0));
         CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
     }
     xDocSh->DoClose();
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index ce9ce2e..92eebc2 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -61,7 +61,13 @@ bool equals( const formula::VectorRefArray& rArray, size_t nPos, const OUString&
     if (!rArray.mpStringArray)
         return false;
 
-    return OUString(rArray.mpStringArray[nPos]).equalsIgnoreAsciiCase(rVal);
+    bool bEquals = OUString(rArray.mpStringArray[nPos]).equalsIgnoreAsciiCase(rVal);
+    if (!bEquals)
+    {
+        cerr << "Expected: " << rVal.toAsciiUpperCase() << " (upcased)" << endl;
+        cerr << "Actual: " << OUString(rArray.mpStringArray[nPos]) << " (upcased)" << endl;
+    }
+    return bEquals;
 }
 
 }
@@ -235,6 +241,34 @@ void Test::testFetchVectorRefArray()
     CPPUNIT_ASSERT_MESSAGE("Array should have a numeric array.", aArray.mpNumericArray);
     CPPUNIT_ASSERT_MESSAGE("Array should NOT have a string array.", !aArray.mpStringArray);
 
+    // Column G consists only of strings.
+    m_pDoc->SetString(ScAddress(6,0,0), "Title");
+    m_pDoc->SetString(ScAddress(6,1,0), "foo");
+    m_pDoc->SetString(ScAddress(6,2,0), "bar");
+    m_pDoc->SetString(ScAddress(6,3,0), "foo");
+    m_pDoc->SetString(ScAddress(6,4,0), "baz");
+    m_pDoc->SetString(ScAddress(6,5,0), "quack");
+    m_pDoc->SetString(ScAddress(6,6,0), "beep");
+    m_pDoc->SetString(ScAddress(6,7,0), "kerker");
+
+    aArray = m_pDoc->FetchVectorRefArray(ScAddress(6,1,0), 4); // G2:G5
+    CPPUNIT_ASSERT_MESSAGE("Failed to fetch vector ref array.", aArray.isValid());
+    CPPUNIT_ASSERT_MESSAGE("Array should NOT have a numeric array.", !aArray.mpNumericArray);
+    CPPUNIT_ASSERT_MESSAGE("Array should have a string array.", aArray.mpStringArray);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 0, "foo"));
+    CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 1, "bar"));
+    CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 2, "foo"));
+    CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 3, "baz"));
+
+    aArray = m_pDoc->FetchVectorRefArray(ScAddress(6,2,0), 4); // G3:G6
+    CPPUNIT_ASSERT_MESSAGE("Failed to fetch vector ref array.", aArray.isValid());
+    CPPUNIT_ASSERT_MESSAGE("Array should NOT have a numeric array.", !aArray.mpNumericArray);
+    CPPUNIT_ASSERT_MESSAGE("Array should have a string array.", aArray.mpStringArray);
+    CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 0, "bar"));
+    CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 1, "foo"));
+    CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 2, "baz"));
+    CPPUNIT_ASSERT_MESSAGE("Unexpected string cell.", equals(aArray, 3, "quack"));
+
     m_pDoc->DeleteTab(0);
 }
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index c7b8f26..b804e82 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2721,7 +2721,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
             {
                 // Requested range falls within the first block.
                 copyFirstStringBlock(*pDocument, rArray, nRow2+1, itBlk);
-                return formula::VectorRefArray(&rArray[0]);
+                return formula::VectorRefArray(&rArray[nRow1]);
             }
 
             copyFirstStringBlock(*pDocument, rArray, itBlk->size, itBlk);


More information about the Libreoffice-commits mailing list