[Libreoffice-commits] core.git: sccomp/qa

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Thu Mar 2 15:15:01 UTC 2017


 sccomp/qa/unit/lpsolver.cxx |   58 +++++++++++++++++---------------------------
 1 file changed, 23 insertions(+), 35 deletions(-)

New commits:
commit b5fb5951c1068446c1546ea0d441484c066c6124
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Thu Mar 2 13:04:21 2017 +0100

    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 at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sccomp/qa/unit/lpsolver.cxx b/sccomp/qa/unit/lpsolver.cxx
index 079d7fc..2754c03 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);


More information about the Libreoffice-commits mailing list