Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
d059866a
Kaydet (Commit)
d059866a
authored
Nis 01, 2014
tarafından
Matúš Kukan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
sccomp: Add very simple unit test for lp solvers.
Change-Id: I359737ad57decf2b1988afbceab85645fbbf1f33
üst
6efbc459
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
182 additions
and
0 deletions
+182
-0
CppunitTest_sccomp_lpsolver.mk
sccomp/CppunitTest_sccomp_lpsolver.mk
+50
-0
Module_sccomp.mk
sccomp/Module_sccomp.mk
+4
-0
lpsolver.cxx
sccomp/qa/unit/lpsolver.cxx
+128
-0
No files found.
sccomp/CppunitTest_sccomp_lpsolver.mk
0 → 100644
Dosyayı görüntüle @
d059866a
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CppunitTest_CppunitTest,sccomp_lpsolver))
$(eval $(call gb_CppunitTest_add_exception_objects,sccomp_lpsolver,\
sccomp/qa/unit/lpsolver \
))
$(eval $(call gb_CppunitTest_use_externals,sccomp_lpsolver,\
boost_headers \
))
$(eval $(call gb_CppunitTest_add_defs,sccomp_lpsolver,\
$(if $(ENABLE_COINMP), -DENABLE_COINMP) \
$(if $(ENABLE_LPSOLVE), -DENABLE_LPSOLVE) \
))
$(eval $(call gb_CppunitTest_use_libraries,sccomp_lpsolver,\
cppu \
sal \
sc \
test \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_set_include,sccomp_lpsolver,\
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_api,sccomp_lpsolver,\
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_use_ure,sccomp_lpsolver))
$(eval $(call gb_CppunitTest_use_rdb,sccomp_lpsolver,services))
$(eval $(call gb_CppunitTest_use_configuration,sccomp_lpsolver))
# vim: set noet sw=4 ts=4:
sccomp/Module_sccomp.mk
Dosyayı görüntüle @
d059866a
...
...
@@ -28,4 +28,8 @@ $(eval $(call gb_Module_add_l10n_targets,sccomp,\
$(if $(ENABLE_COINMP)$(ENABLE_LPSOLVE), AllLangResTarget_solver) \
))
$(eval $(call gb_Module_add_check_targets,sccomp,\
CppunitTest_sccomp_lpsolver \
))
# vim: set noet sw=4 ts=4:
sccomp/qa/unit/lpsolver.cxx
0 → 100644
Dosyayı görüntüle @
d059866a
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sal/config.h>
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/sheet/XSolver.hpp>
#include <com/sun/star/sheet/XSolverDescription.hpp>
#include <test/bootstrapfixture.hxx>
#include <address.hxx>
using
namespace
css
;
namespace
{
class
LpSolverTest
:
public
test
::
BootstrapFixture
{
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
m_xDocument
;
void
test
();
void
testSolver
(
const
uno
::
Reference
<
sheet
::
XSolver
>&
xSolver
);
public
:
virtual
void
setUp
()
SAL_OVERRIDE
;
virtual
void
tearDown
()
SAL_OVERRIDE
;
CPPUNIT_TEST_SUITE
(
LpSolverTest
);
CPPUNIT_TEST
(
test
);
CPPUNIT_TEST_SUITE_END
();
};
void
LpSolverTest
::
setUp
()
{
test
::
BootstrapFixture
::
setUp
();
uno
::
Reference
<
frame
::
XDesktop2
>
xComponentLoader
=
frame
::
Desktop
::
create
(
m_xContext
);
uno
::
Reference
<
lang
::
XComponent
>
xComponent
(
xComponentLoader
->
loadComponentFromURL
(
"private:factory/scalc"
,
"_blank"
,
0
,
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>
()));
m_xDocument
.
set
(
xComponent
,
uno
::
UNO_QUERY_THROW
);
}
void
LpSolverTest
::
tearDown
()
{
uno
::
Reference
<
lang
::
XComponent
>
(
m_xDocument
,
uno
::
UNO_QUERY_THROW
)
->
dispose
();
test
::
BootstrapFixture
::
tearDown
();
}
void
LpSolverTest
::
test
()
{
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
;
#endif
CPPUNIT_ASSERT_EQUAL
(
nExpected
,
nCount
);
}
void
LpSolverTest
::
testSolver
(
const
uno
::
Reference
<
sheet
::
XSolver
>&
xSolver
)
{
table
::
CellAddress
aObjective
(
0
,
0
,
0
);
// "changing cells" - unknown variables
uno
::
Sequence
<
table
::
CellAddress
>
aVariables
(
1
);
aVariables
[
0
]
=
table
::
CellAddress
(
0
,
0
,
0
);
// constraints
uno
::
Sequence
<
sheet
::
SolverConstraint
>
aConstraints
(
1
);
aConstraints
[
0
].
Left
=
table
::
CellAddress
(
0
,
0
,
0
);
aConstraints
[
0
].
Operator
=
sheet
::
SolverConstraintOperator_LESS_EQUAL
;
aConstraints
[
0
].
Right
<<=
5.0
;
// initialize solver
xSolver
->
setDocument
(
m_xDocument
);
xSolver
->
setObjective
(
aObjective
);
xSolver
->
setVariables
(
aVariables
);
xSolver
->
setConstraints
(
aConstraints
);
xSolver
->
setMaximize
(
true
);
// test results
xSolver
->
solve
();
CPPUNIT_ASSERT
(
xSolver
->
getSuccess
());
uno
::
Sequence
<
double
>
aSolution
=
xSolver
->
getSolution
();
CPPUNIT_ASSERT_EQUAL
(
aSolution
.
getLength
(),
aVariables
.
getLength
());
CPPUNIT_ASSERT_EQUAL
(
aSolution
[
0
],
(
double
)
5.0
);
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
LpSolverTest
);
}
CPPUNIT_PLUGIN_IMPLEMENT
();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment