sc/qa/unit/ucalc_formula.cxx | 71 ++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 17 deletions(-)
New commits: commit b24286e46ebd0dbc2acbea30627572a66707f346 Author: Åukasz Hryniuk <[email protected]> Date: Fri Sep 25 14:56:11 2015 +0200 Testcases with several arrays for SUM and PRODUCT Change-Id: I0e710b6a53af3aa062a17e0a998691e1ec6d3973 diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 195343b..58d1e6b 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -3390,6 +3390,13 @@ void Test::testFuncPRODUCT() m_pDoc->SetString(aPos, OUString("=PRODUCT({8;0.125;-1})")); CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT with inline array failed", -1.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, OUString("=PRODUCT({2;3};{4;5})")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT with inline array failed", 120.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, OUString("=PRODUCT({10;-8};{3;-1};{15;30};{7})")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT with inline array failed", 756000.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, OUString("=PRODUCT({10;-0.1;8};{0.125;4;0.25;2};{0.5};{1};{-1})")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT with inline array failed", 1.0, m_pDoc->GetValue(aPos)); + m_pDoc->DeleteTab(0); } @@ -6364,6 +6371,15 @@ void Test::testFuncSUMSQ() m_pDoc->SetString(aPos, "=SUMSQ({\"a\";-4;-5})"); CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 41.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=SUMSQ({2;3};{4;5})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 54.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=SUMSQ({-3;3;1};{-1})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 20.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=SUMSQ({-4};{1;4;2};{-5;7};{9})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 192.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=SUMSQ({-2;2};{1};{-1};{0;0;0;4})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 26.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=SUMSQ(4;1;-3)"); CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMSQ for failed", 26.0, m_pDoc->GetValue(aPos)); m_pDoc->SetString(aPos, "=SUMSQ(0;5;13;-7;-4)"); commit 2b0413a7d79f9df0b29bc2f27599b95eba1c7bdc Author: Åukasz Hryniuk <[email protected]> Date: Fri Sep 25 14:38:42 2015 +0200 Broaden PRODUCT test Change-Id: I3abeb0c958031202da869084ffa24c11b8a47592 diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 49fdd5f..195343b 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -3351,23 +3351,44 @@ void Test::testFuncPRODUCT() sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc. OUString aTabName("foo"); - CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", - m_pDoc->InsertTab (0, aTabName)); - - double val = 1; - double result; - m_pDoc->SetValue(0, 0, 0, val); - val = 2; - m_pDoc->SetValue(0, 1, 0, val); - val = 3; - m_pDoc->SetValue(0, 2, 0, val); - m_pDoc->SetString(0, 3, 0, OUString("=PRODUCT(A1:A3)")); - m_pDoc->GetValue(0, 3, 0, result); - CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT failed", result == 6.0); - - m_pDoc->SetString(0, 4, 0, OUString("=PRODUCT({2;3;4})")); - m_pDoc->GetValue(0, 4, 0, result); - CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT with inline array failed", result == 24.0); + CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab(0, aTabName)); + + ScAddress aPos(3, 0, 0); + m_pDoc->SetValue(0, 0, 0, 3.0); // A1 + m_pDoc->SetString(aPos, OUString("=PRODUCT(A1)")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT failed", 3.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(0, 0, 0, -3.0); // A1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT failed", -3.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, OUString("=PRODUCT(B1)")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT failed", 0.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(1, 0, 0, 10.0); // B1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT failed", 10.0, m_pDoc->GetValue(aPos)); + + m_pDoc->SetString(aPos, OUString("=PRODUCT(A1:C3)")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT failed", -30.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(1, 1, 0, -1.0); // B2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT failed", 30.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(2, 0, 0, 4.0); // C1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT failed", 120.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(0, 1, 0, -2.0); // A2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT failed", -240.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(2, 1, 0, 8.0); // C2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT failed", -1920.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(0, 2, 0, 0.2); // A3 + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of PRODUCT failed", -384.0, m_pDoc->GetValue(aPos), 10e-4); + m_pDoc->SetValue(1, 2, 0, -0.25); // B3 + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of PRODUCT failed", 96.0, m_pDoc->GetValue(aPos), 10e-4); + m_pDoc->SetValue(2, 2, 0, -0.125); // C3 + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of PRODUCT failed", -12.0, m_pDoc->GetValue(aPos), 10e-4); + m_pDoc->SetValue(2, 2, 0, 0.0); // C3 + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculation of PRODUCT failed", 0.0, m_pDoc->GetValue(aPos), 10e-4); + + m_pDoc->SetString(aPos, OUString("=PRODUCT({2;3;4})")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT with inline array failed", 24.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, OUString("=PRODUCT({2;-2;2})")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT with inline array failed", -8.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, OUString("=PRODUCT({8;0.125;-1})")); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of PRODUCT with inline array failed", -1.0, m_pDoc->GetValue(aPos)); m_pDoc->DeleteTab(0); }
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
