summaryrefslogtreecommitdiff
path: root/sccomp/qa/unit
diff options
context:
space:
mode:
Diffstat (limited to 'sccomp/qa/unit')
-rw-r--r--sccomp/qa/unit/lpsolver.cxx58
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);