diff options
author | Łukasz Hryniuk <lukasz.hryniuk@wp.pl> | 2015-09-24 19:36:25 +0200 |
---|---|---|
committer | Łukasz Hryniuk <lukasz.hryniuk@wp.pl> | 2015-09-25 00:57:21 +0200 |
commit | 14ccaf915d09da23b07e8604b78c449c389a15cc (patch) | |
tree | 4b75381297b13f2936ee74284d7f4a9328e481b1 /sc | |
parent | 5e1944c70b6423b47e1490df7920217e83d662c9 (diff) |
Test for SUMX2MY2
Change-Id: I6a40cc0104ce8ced879749190f1ff406044736ab
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 76 |
2 files changed, 78 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 37e4433cb3be..53482ca4dab5 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -188,6 +188,7 @@ public: void testFuncFTESTBug(); void testFuncCHITEST(); void testFuncSUMX2PY2(); + void testFuncSUMX2MY2(); void testFuncGCD(); void testFuncLCM(); void testFuncSUMSQ(); @@ -525,6 +526,7 @@ public: CPPUNIT_TEST_FAIL(testFuncFTESTBug); CPPUNIT_TEST(testFuncCHITEST); CPPUNIT_TEST(testFuncSUMX2PY2); + CPPUNIT_TEST(testFuncSUMX2MY2); CPPUNIT_TEST(testFuncGCD); CPPUNIT_TEST(testFuncLCM); CPPUNIT_TEST(testFuncSUMSQ); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 8a1ebd78a9a9..49fdd5fd690f 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -6051,6 +6051,82 @@ void Test::testFuncSUMX2PY2() m_pDoc->DeleteTab(0); } +void Test::testFuncSUMX2MY2() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + + m_pDoc->InsertTab(0, "SumX2MY2 Test"); + + OUString aVal; + ScAddress aPos(6,0,0); + m_pDoc->SetString(aPos, "=SUMX2MY2(A1:C3;D1:F3)"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 0.0, m_pDoc->GetValue(aPos)); + + m_pDoc->SetValue(0, 0, 0, 10.0); // A1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 0.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(3, 0, 0, -9.0); // D1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 19.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(1, 0, 0, 2.0); // B1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 19.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(4, 0, 0, 1.0); // E1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(2, 0, 0, 3.0); // C1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(5, 0, 0, 3.0); // F1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(0, 1, 0, 10.0); // A2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(3, 1, 0, -10.0); // D2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(1, 1, 0, -5.0); // B2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(4, 1, 0, -5.0); // E2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(2, 1, 0, -3.0); // C2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(5, 1, 0, 3.0); // F2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(0, 2, 0, -8.0); // A3 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 22.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(3, 2, 0, 3.0); // D3 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 77.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(1, 2, 0, 2.0); // B3 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 77.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(4, 2, 0, -6.0); // E3 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 45.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(2, 2, 0, -4.0); // C3 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 45.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetValue(5, 2, 0, 6.0); // F3 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 25.0, m_pDoc->GetValue(aPos)); + + // add some strings + m_pDoc->SetString(5, 2, 0, "a"); // F3 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 45.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(0, 2, 0, "a"); // A3 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", -10.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(1, 0, 0, "a"); // B1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", -13.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(3, 0, 0, "a"); // D1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", -32.0, m_pDoc->GetValue(aPos)); + + m_pDoc->SetString(aPos, "=SUMX2MY2({1;3;5};{0;4;4})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 3.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=SUMX2MY2({1;-3;-5};{0;-4;4})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 3.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=SUMX2MY2({9;5;1};{3;-3;3})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of SUMX2MY2 failed", 80.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=SUMX2MY2({1;2;3};{2;3})"); + aVal = m_pDoc->GetString(aPos); + CPPUNIT_ASSERT_EQUAL_MESSAGE("SUMX2MY2 should return #VALUE! for matrices with different sizes", + OUString("#VALUE!"), aVal); + m_pDoc->SetString(aPos, "=SUMX2MY2({1;2;3})"); + aVal = m_pDoc->GetString(aPos); + CPPUNIT_ASSERT_EQUAL_MESSAGE("SUMX2MY2 needs two parameters", + OUString("Err:511"), aVal); + + m_pDoc->DeleteTab(0); +} + void Test::testFuncGCD() { sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. |