summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-02-07 11:45:07 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-02-07 12:00:39 -0500
commit6437313bdba12836d9e472654ad402601af58077 (patch)
treea88a1bacbd5b661fed4b2d7c0dcc0f5539d500b3
parent850d1b784de3cb575a3e12269651d36fce32dfd0 (diff)
fdo#74507: Write test for this to induce the crash during unit test run.
Change-Id: Ib25136c203f7da17a9b7f086916d870225bc729b
-rw-r--r--sc/qa/unit/ucalc.cxx37
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 39 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 596bd92c7954..275e4a04eadf 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -56,6 +56,7 @@
#include <asciiopt.hxx>
#include <impex.hxx>
#include <columnspanset.hxx>
+#include <docoptio.hxx>
#include "formula/IFunctionDescription.hxx"
@@ -1189,6 +1190,42 @@ void Test::testHorizontalIterator()
m_pDoc->DeleteTab(0);
}
+void Test::testValueIterator()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ // Turn on "precision as shown" option.
+ ScDocOptions aOpt = m_pDoc->GetDocOptions();
+ aOpt.SetCalcAsShown(true);
+ m_pDoc->SetDocOptions(aOpt);
+
+ // Purely horizontal data layout with numeric data.
+ for (SCCOL i = 1; i <= 3; ++i)
+ m_pDoc->SetValue(ScAddress(i,2,0), i);
+
+ double fVal;
+ sal_uInt16 nErr;
+
+ {
+ const double aChecks[] = { 1.0, 2.0, 3.0 };
+ size_t nCheckLen = SAL_N_ELEMENTS(aChecks);
+
+ ScValueIterator aIter(m_pDoc, ScRange(1,2,0,3,2,0));
+ bool bHas = false;
+
+ size_t nCheckPos = 0;
+ for (bHas = aIter.GetFirst(fVal, nErr); bHas; bHas = aIter.GetNext(fVal, nErr), ++nCheckPos)
+ {
+ CPPUNIT_ASSERT_MESSAGE("Iteration longer than expected.", nCheckPos < nCheckLen);
+ CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos], fVal);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0), nErr);
+ }
+ }
+
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFormulaDepTracking()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "foo"));
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index dfa3a4b0ec7b..74b79a399486 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -137,6 +137,7 @@ public:
void testVolatileFunc();
void testHorizontalIterator();
+ void testValueIterator();
/**
* Basic test for formula dependency tracking.
@@ -361,6 +362,7 @@ public:
CPPUNIT_TEST(testSheetsFunc);
CPPUNIT_TEST(testVolatileFunc);
CPPUNIT_TEST(testHorizontalIterator);
+ CPPUNIT_TEST(testValueIterator);
CPPUNIT_TEST(testFormulaDepTracking);
CPPUNIT_TEST(testFormulaDepTracking2);
CPPUNIT_TEST(testCellBroadcaster);