From b5fb5951c1068446c1546ea0d441484c066c6124 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 2 Mar 2017 13:04:21 +0100 Subject: change the solver test to explicitly test the available solvers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tomaž Vajngerl --- sccomp/qa/unit/lpsolver.cxx | 58 ++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 35 deletions(-) (limited to 'sccomp/qa') 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 m_xDocument; - void test(); - void testSolver(const uno::Reference& 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 xEnAc( - m_xContext->getServiceManager(), uno::UNO_QUERY_THROW); - uno::Reference xEnum = xEnAc-> - createContentEnumeration( "com.sun.star.sheet.Solver" ); - CPPUNIT_ASSERT(xEnum.is()); - - sal_Int32 nCount = 0; - while (xEnum->hasMoreElements()) - { - uno::Reference xIntFac; - xEnum->nextElement() >>= xIntFac; - CPPUNIT_ASSERT(xIntFac.is()); - uno::Reference xInfo(xIntFac, uno::UNO_QUERY_THROW); - const OUString sName(xInfo->getImplementationName()); - uno::Reference xSolver(m_xContext->getServiceManager()-> - createInstanceWithContext(sName, m_xContext), uno::UNO_QUERY_THROW); - testSolver(xSolver); - - uno::Reference 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& xSolver) +void LpSolverTest::testSolver(OUString const & rName) { + uno::Reference 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& xSolver) uno::Sequence aSolution = xSolver->getSolution(); CPPUNIT_ASSERT_EQUAL(aSolution.getLength(), aVariables.getLength()); CPPUNIT_ASSERT_EQUAL(aSolution[0], (double)5.0); + + uno::Reference 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); -- cgit v1.2.3