[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter' - sc/qa sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Thu Jul 11 10:31:56 PDT 2013
sc/qa/unit/ucalc.cxx | 45 ++++++++++++++++++++++++++++++++++++++-
sc/source/core/tool/scmatrix.cxx | 4 +++
2 files changed, 48 insertions(+), 1 deletion(-)
New commits:
commit dc2064c5c3d872b778685a73a744d7249056e857
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu Jul 11 13:26:04 2013 -0400
Add test case for matrix's double array handling & fix one bug.
Conflicts:
sc/qa/unit/ucalc.cxx
Change-Id: I6cb2ff8bf536ccb53ae9f146baf6aa582f9fbcfe
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 5ea6597..c054b67 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2437,7 +2437,7 @@ struct PartiallyFilledEmptyMatrix
void Test::testMatrix()
{
- ScMatrixRef pMat;
+ ScMatrixRef pMat, pMat2;
// First, test the zero matrix type.
pMat = new ScMatrix(0, 0, 0.0);
@@ -2518,6 +2518,49 @@ void Test::testMatrix()
pMat->PutDouble(12.5, 1, 1);
CPPUNIT_ASSERT_EQUAL(0.0, pMat->GetMinValue(false));
CPPUNIT_ASSERT_EQUAL(12.5, pMat->GetMaxValue(false));
+
+ // Convert matrix into a linear double array. String elements become NaN
+ // and empty elements become 0.
+ pMat = new ScMatrix(3, 3);
+ pMat->PutDouble(2.5, 0, 0);
+ pMat->PutDouble(1.2, 0, 1);
+ pMat->PutString("A", 1, 1);
+ pMat->PutDouble(2.3, 2, 1);
+ pMat->PutDouble(-20, 2, 2);
+
+ double fNaN;
+ rtl::math::setNan(&fNaN);
+
+ std::vector<double> aDoubles;
+ pMat->GetDoubleArray(aDoubles);
+
+ {
+ const double pChecks[] = { 2.5, 1.2, 0, 0, fNaN, 0, 0, 2.3, -20 };
+ CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(pChecks), aDoubles.size());
+ for (size_t i = 0, n = aDoubles.size(); i < n; ++i)
+ {
+ if (rtl::math::isNan(pChecks[i]))
+ CPPUNIT_ASSERT_MESSAGE("NaN is expected, but it's not.", rtl::math::isNan(aDoubles[i]));
+ else
+ CPPUNIT_ASSERT_EQUAL(pChecks[i], aDoubles[i]);
+ }
+ }
+
+ pMat2 = new ScMatrix(3, 3, 10.0);
+ pMat2->PutString("B", 1, 0);
+ pMat2->MergeDoubleArray(aDoubles, ScMatrix::Mul);
+
+ {
+ const double pChecks[] = { 25, 12, 0, fNaN, fNaN, 0, 0, 23, -200 };
+ CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(pChecks), aDoubles.size());
+ for (size_t i = 0, n = aDoubles.size(); i < n; ++i)
+ {
+ if (rtl::math::isNan(pChecks[i]))
+ CPPUNIT_ASSERT_MESSAGE("NaN is expected, but it's not.", rtl::math::isNan(aDoubles[i]));
+ else
+ CPPUNIT_ASSERT_EQUAL(pChecks[i], aDoubles[i]);
+ }
+ }
}
void Test::testEnterMixedMatrix()
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index ffc3382..3980ef6 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -1063,6 +1063,8 @@ public:
*miPos = mfNaN;
}
break;
+ case mdds::mtm::element_empty:
+ std::advance(miPos, node.size);
default:
;
}
@@ -1133,6 +1135,8 @@ public:
*miPos = mfNaN;
}
break;
+ case mdds::mtm::element_empty:
+ std::advance(miPos, node.size);
default:
;
}
More information about the Libreoffice-commits
mailing list