diff options
author | giacco <filippo.giacche@gmail.com> | 2017-02-10 00:13:29 +0000 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-02-16 17:28:48 +0000 |
commit | c995531d8a7c97f684f2e65707c7b3f87a0ba372 (patch) | |
tree | 0d6fa703ba6b8053b2bf6ac78ef77a7b628ecb7e /sc/qa | |
parent | e16644fa1c042b56a1301f0476d7ddb71c8765ea (diff) |
tdf#89387 improve performance for some matrix operations
add method in scmatrix to get Gcd and lcm
modified function scinterpreter::ScGcd() and scinterpreter::ScLcm()
now should be ok
Change-Id: I1e41fa5707bc4b637a986f2fc0a2358ac0121af1
Reviewed-on: https://gerrit.libreoffice.org/34110
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index cec64f16d15c..1fde2916d369 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -6976,6 +6976,20 @@ void Test::testFuncGCD() CPPUNIT_ASSERT_EQUAL_MESSAGE("GCD should return Err:502 for a array with strings", OUString("Err:502"), aVal); + //many inline array + m_pDoc->SetString(aPos, "=GCD({6;6;6};{3;6;9})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of GCD for failed", 3.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=GCD({300;300;300};{150;0})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of GCD for failed", 150.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos,"=GCD({3;6;9};{3;-6;9})"); + aVal = m_pDoc->GetString(aPos); + CPPUNIT_ASSERT_EQUAL_MESSAGE("GCD should return Err:502 for a array with values less then 0", + OUString("Err:502"), aVal); + m_pDoc->SetString(aPos, "=GCD({3;6;9};{\"a\";6;9})"); + aVal = m_pDoc->GetString(aPos); + CPPUNIT_ASSERT_EQUAL_MESSAGE("GCD should return Err:502 for a array with strings", + OUString("Err:502"), aVal); + // inline list of values m_pDoc->SetString(aPos, "=GCD(12;24;36;48;60)"); CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of GCD for failed", 12.0, m_pDoc->GetValue(aPos)); @@ -7059,6 +7073,20 @@ void Test::testFuncLCM() CPPUNIT_ASSERT_EQUAL_MESSAGE("LCM should return Err:502 for a array with strings", OUString("Err:502"), aVal); + //many inline array + m_pDoc->SetString(aPos, "=LCM({6;6;6};{3;6;9})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of LCM for failed", 18.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos, "=LCM({300;300;300};{150;0})"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of LCM for failed", 0.0, m_pDoc->GetValue(aPos)); + m_pDoc->SetString(aPos,"=LCM({3;6;9};{3;-6;9})"); + aVal = m_pDoc->GetString(aPos); + CPPUNIT_ASSERT_EQUAL_MESSAGE("LCM should return Err:502 for a array with values less then 0", + OUString("Err:502"), aVal); + m_pDoc->SetString(aPos, "=LCM({3;6;9};{\"a\";6;9})"); + aVal = m_pDoc->GetString(aPos); + CPPUNIT_ASSERT_EQUAL_MESSAGE("LCM should return Err:502 for a array with strings", + OUString("Err:502"), aVal); + m_pDoc->SetString(aPos, "=LCM(12;24;36;48;60)"); CPPUNIT_ASSERT_EQUAL_MESSAGE("Calculation of LCM for failed", 720.0, m_pDoc->GetValue(aPos)); m_pDoc->SetString(aPos, "=LCM(0;12;24;36;48;60)"); |