sc/qa/unit/ucalc.cxx | 19 +++++++++++++++++++ sc/source/core/tool/scmatrix.cxx | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-)
New commits: commit 93a1f731c17059d1e5d254061dcee7c4a6781859 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Fri Jun 28 19:37:50 2013 -0400 Add tests for matrix's min and max values, and fix one bug. Apparently numeric_limits<type>::min() is not to be used for signed types. Change-Id: Ia9730328562905459eb1d3e5cfd1a023c644e219 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index be470b1..c7eda91 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -2562,6 +2562,25 @@ void Test::testMatrix() CPPUNIT_ASSERT_EQUAL(1.5, pMat->GetDouble(0, 1)); CPPUNIT_ASSERT_EQUAL(1.5, pMat->GetDouble(1, 0)); CPPUNIT_ASSERT_MESSAGE("PutEmpty() call failed.", pMat->IsEmpty(1, 1)); + + // Max and min values. + pMat = new ScMatrix(2, 2, 0.0); + pMat->PutDouble(-10, 0, 0); + pMat->PutDouble(-12, 0, 1); + pMat->PutDouble(-8, 1, 0); + pMat->PutDouble(-25, 1, 1); + CPPUNIT_ASSERT_EQUAL(-25.0, pMat->GetMinValue(false)); + CPPUNIT_ASSERT_EQUAL(-8.0, pMat->GetMaxValue(false)); + pMat->PutString("Test", 0, 0); + CPPUNIT_ASSERT_EQUAL(0.0, pMat->GetMaxValue(true)); // text as zero. + CPPUNIT_ASSERT_EQUAL(-8.0, pMat->GetMaxValue(false)); // ignore text. + pMat->PutBoolean(true, 0, 0); + CPPUNIT_ASSERT_EQUAL(1.0, pMat->GetMaxValue(false)); + pMat = new ScMatrix(2, 2, 10.0); + pMat->PutBoolean(false, 0, 0); + pMat->PutDouble(12.5, 1, 1); + CPPUNIT_ASSERT_EQUAL(0.0, pMat->GetMinValue(false)); + CPPUNIT_ASSERT_EQUAL(12.5, pMat->GetMaxValue(false)); } void Test::testEnterMixedMatrix() diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index bf3ea63..b0bef2e 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -940,7 +940,7 @@ public: struct MaxOp { - static double init() { return std::numeric_limits<double>::min(); } + static double init() { return -std::numeric_limits<double>::max(); } static double compare(double left, double right) { return std::max(left, right); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits