diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2017-03-02 13:04:21 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2017-03-02 15:14:30 +0000 |
commit | b5fb5951c1068446c1546ea0d441484c066c6124 (patch) | |
tree | 38a4d1c7d7d4772f6c41c587f7df6a51c2d825af /sccomp/qa | |
parent | fix leak (diff) | |
download | core-b5fb5951c1068446c1546ea0d441484c066c6124.tar.gz core-b5fb5951c1068446c1546ea0d441484c066c6124.zip |
change the solver test to explicitly test the available solvers
This changes the lpsolver test to explicitly test the available
linear solvers we have - either CoinMP, LpSolver or both. This
prevents that a newly added solver will be automatically tested
as it can have a different behaviour for the tested input values.
Change-Id: I0c4d2f9c561d1e834ca51196b7b5ecf7d89ba550
Reviewed-on: https://gerrit.libreoffice.org/34813
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sccomp/qa')
-rw-r--r-- | sccomp/qa/unit/lpsolver.cxx | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/sccomp/qa/unit/lpsolver.cxx b/sccomp/qa/unit/lpsolver.cxx index 079d7fca41c8..2754c03bc754 100644 --- a/sccomp/qa/unit/lpsolver.cxx +++ b/sccomp/qa/unit/lpsolver.cxx @@ -26,15 +26,18 @@ class LpSolverTest: public test::BootstrapFixture { uno::Reference<sheet::XSpreadsheetDocument> m_xDocument; - void test(); - void testSolver(const uno::Reference<sheet::XSolver>& xSolver); + void testLpSolver(); + void testCoinMPSolver(); + + void testSolver(OUString const & rName); public: virtual void setUp() override; virtual void tearDown() override; CPPUNIT_TEST_SUITE(LpSolverTest); - CPPUNIT_TEST(test); + CPPUNIT_TEST(testLpSolver); + CPPUNIT_TEST(testCoinMPSolver); CPPUNIT_TEST_SUITE_END(); }; @@ -54,44 +57,25 @@ void LpSolverTest::tearDown() test::BootstrapFixture::tearDown(); } -void LpSolverTest::test() +void LpSolverTest::testLpSolver() { - uno::Reference<container::XContentEnumerationAccess> xEnAc( - m_xContext->getServiceManager(), uno::UNO_QUERY_THROW); - uno::Reference<container::XEnumeration> xEnum = xEnAc-> - createContentEnumeration( "com.sun.star.sheet.Solver" ); - CPPUNIT_ASSERT(xEnum.is()); - - sal_Int32 nCount = 0; - while (xEnum->hasMoreElements()) - { - uno::Reference<uno::XInterface> xIntFac; - xEnum->nextElement() >>= xIntFac; - CPPUNIT_ASSERT(xIntFac.is()); - uno::Reference<lang::XServiceInfo> xInfo(xIntFac, uno::UNO_QUERY_THROW); - const OUString sName(xInfo->getImplementationName()); - uno::Reference<sheet::XSolver> xSolver(m_xContext->getServiceManager()-> - createInstanceWithContext(sName, m_xContext), uno::UNO_QUERY_THROW); - testSolver(xSolver); - - uno::Reference<sheet::XSolverDescription> xDesc(xSolver, uno::UNO_QUERY_THROW); - const OString sMessage("Empty description for " + - OUStringToOString(sName, RTL_TEXTENCODING_UTF8)); - CPPUNIT_ASSERT_MESSAGE(sMessage.getStr(), !xDesc->getComponentDescription().isEmpty()); - ++nCount; - } - sal_Int32 nExpected = 0; -#ifdef ENABLE_COINMP - ++nExpected; -#endif #ifdef ENABLE_LPSOLVE - ++nExpected; + testSolver("com.sun.star.comp.Calc.LpsolveSolver"); +#endif +} + +void LpSolverTest::testCoinMPSolver() +{ +#ifdef ENABLE_COINMP + testSolver("com.sun.star.comp.Calc.CoinMPSolver"); #endif - CPPUNIT_ASSERT_EQUAL(nExpected, nCount); } -void LpSolverTest::testSolver(const uno::Reference<sheet::XSolver>& xSolver) +void LpSolverTest::testSolver(OUString const & rName) { + uno::Reference<sheet::XSolver> xSolver(m_xContext->getServiceManager()-> + createInstanceWithContext(rName, m_xContext), uno::UNO_QUERY_THROW); + table::CellAddress aObjective(0, 0, 0); // "changing cells" - unknown variables @@ -117,6 +101,10 @@ void LpSolverTest::testSolver(const uno::Reference<sheet::XSolver>& xSolver) uno::Sequence<double> aSolution = xSolver->getSolution(); CPPUNIT_ASSERT_EQUAL(aSolution.getLength(), aVariables.getLength()); CPPUNIT_ASSERT_EQUAL(aSolution[0], (double)5.0); + + uno::Reference<sheet::XSolverDescription> xDesc(xSolver, uno::UNO_QUERY_THROW); + const OString sMessage("Empty description for " + OUStringToOString(rName, RTL_TEXTENCODING_UTF8)); + CPPUNIT_ASSERT_MESSAGE(sMessage.getStr(), !xDesc->getComponentDescription().isEmpty()); } CPPUNIT_TEST_SUITE_REGISTRATION(LpSolverTest); |