diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-31 12:35:30 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-31 12:36:31 -0400 |
commit | 94a569c25026ea67f18ace8a075e13ac355ff3d2 (patch) | |
tree | 6cdfe749d8d6a6f6714856e9163f0588bacda81c | |
parent | 6d2f42199c2a9b48c9e19d7ae087f5452bfbd401 (diff) |
Don't hard-code the start row position of string array to 0...
Change-Id: I06724e2e8754ac20217f5375a445c85f9a5b31e6
-rw-r--r-- | sc/qa/unit/opencl-test.cxx | 7 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 36 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 2 |
3 files changed, 39 insertions, 6 deletions
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx index cf5fa7ec82d4..862d24c6c6ec 100644 --- a/sc/qa/unit/opencl-test.cxx +++ b/sc/qa/unit/opencl-test.cxx @@ -237,13 +237,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 ce9ce2ecf730..92eebc245480 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 5176d82fea2e..4715b480fc7b 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2722,7 +2722,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); |