From 7b7acc2f2b5776ec0359272a3f729fc5b804a1e5 Mon Sep 17 00:00:00 2001 From: pkv Date: Fri, 13 Nov 2009 09:10:16 +0000 Subject: [PATCH] Adds Notebook CPP UNIT tests --- configure.ac | 1 + src/Makefile.am | 3 +- src/Notebook/Test/Makefile.am | 107 ++++++++++ src/Notebook/Test/NotebookTest.cxx | 324 +++++++++++++++++++++++++++++ src/Notebook/Test/NotebookTest.hxx | 46 ++++ src/Notebook/Test/TestNotebook.cxx | 34 +++ 6 files changed, 514 insertions(+), 1 deletion(-) create mode 100644 src/Notebook/Test/Makefile.am create mode 100644 src/Notebook/Test/NotebookTest.cxx create mode 100644 src/Notebook/Test/NotebookTest.hxx create mode 100644 src/Notebook/Test/TestNotebook.cxx diff --git a/configure.ac b/configure.ac index 27b246832..e8960ae94 100644 --- a/configure.ac +++ b/configure.ac @@ -579,5 +579,6 @@ AC_OUTPUT([ \ src/UnitTests/Makefile \ src/Utils/Makefile \ src/Utils/Test/Makefile \ + src/Notebook/Test/Makefile \ ]) diff --git a/src/Makefile.am b/src/Makefile.am index feed604c0..f9f92b6e5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -69,7 +69,8 @@ SUBDIR_CPPUNIT_CORBA = \ LifeCycleCORBA/Test \ LifeCycleCORBA_SWIG/Test \ SALOMEDSImpl/Test \ - SALOMEDS/Test + SALOMEDS/Test \ + Notebook/Test SUBDIR_CPPUNIT_GENERAL = \ UnitTests diff --git a/src/Notebook/Test/Makefile.am b/src/Notebook/Test/Makefile.am new file mode 100644 index 000000000..ea3164d53 --- /dev/null +++ b/src/Notebook/Test/Makefile.am @@ -0,0 +1,107 @@ +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# File : Makefile.am +# Author : +# Module : KERNEL +# $Header$ +# +include $(top_srcdir)/salome_adm/unix/make_common_starter.am + +# +# =============================================================== +# Files to be installed +# =============================================================== +# +# header files +salomeinclude_HEADERS= NotebookTest.hxx + +# Scripts to be installed +#dist_salomescript_PYTHON = TestNotebook.py + +# +# =============================================================== +# Local definitions +# =============================================================== +# + +# This directory defines the subdirectory src in the top source directory. +RPATH=../.. + +# This local variable defines the list of CPPFLAGS common to all target in this package. +COMMON_CPPFLAGS=\ + @CPPUNIT_INCLUDES@ \ + -I$(srcdir)/$(RPATH)/Basics -I$(srcdir)/$(RPATH)/Basics/Test \ + -I$(srcdir)/$(RPATH)/SALOMELocalTrace -I$(srcdir)/$(RPATH)/SALOMELocalTrace/Test \ + -I$(srcdir)/$(RPATH)/SALOMETraceCollector -I$(srcdir)/$(RPATH)/SALOMETraceCollector/Test \ + -I$(srcdir)/$(RPATH)/NamingService -I$(srcdir)/$(RPATH)/NamingService/Test \ + -I$(srcdir)/$(RPATH)/Utils -I$(srcdir)/$(RPATH)/Utils/Test \ + -I$(srcdir)/$(RPATH)/ResourcesManager \ + -I$(srcdir)/$(RPATH)/LifeCycleCORBA \ + -I$(srcdir)/$(RPATH)/DF \ + -I$(srcdir)/$(RPATH)/SALOMEDSImpl \ + -I$(srcdir)/$(RPATH)/Notebook \ + -I$(top_builddir)/idl \ + @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @BOOST_CPPFLAGS@ + +# This local variable defines the list of dependant libraries common to all target in this package. +COMMON_LIBS =\ + @CPPUNIT_LIBS@ \ + $(RPATH)/Basics/libSALOMEBasics.la \ + $(RPATH)/ResourcesManager/libSalomeResourcesManager.la \ + $(RPATH)/Container/libSalomeContainer.la \ + $(RPATH)/NamingService/libSalomeNS.la \ + $(RPATH)/Registry/libRegistry.la \ + $(RPATH)/Notification/libSalomeNotification.la \ + $(RPATH)/Utils/Test/libUtilsTest.la \ + $(RPATH)/Utils/libOpUtil.la \ + $(RPATH)/SALOMELocalTrace/Test/libSALOMELocalTraceTest.la \ + $(RPATH)/SALOMELocalTrace/libSALOMELocalTrace.la \ + $(RPATH)/SALOMETraceCollector/Test/libSALOMETraceCollectorTest.la \ + $(RPATH)/DF/libDF.la \ + $(RPATH)/SALOMEDSImpl/libSalomeDSImpl.la \ + $(RPATH)/HDFPersist/libSalomeHDFPersist.la \ + $(top_builddir)/idl/libSalomeIDLKernel.la + +# +# =============================================================== +# Libraries targets +# =============================================================== +# +lib_LTLIBRARIES = libNotebookTest.la +libNotebookTest_la_SOURCES = NotebookTest.cxx +libNotebookTest_la_CPPFLAGS = $(COMMON_CPPFLAGS) +libNotebookTest_la_LDFLAGS = -no-undefined -version-info=0:0:0 +libNotebookTest_la_LIBADD = $(COMMON_LIBS) + +# +# =============================================================== +# Executables targets +# =============================================================== +# +bin_PROGRAMS = TestNotebook +TestNotebook_SOURCES = TestNotebook.cxx +TestNotebook_CPPFLAGS = $(COMMON_CPPFLAGS) +TestNotebook_LDADD = \ + libNotebookTest.la ../libSalomeNotebook.la \ + $(RPATH)/NamingService/Test/libNamingServiceTest.la \ + $(COMMON_LIBS) + diff --git a/src/Notebook/Test/NotebookTest.cxx b/src/Notebook/Test/NotebookTest.cxx new file mode 100644 index 000000000..b9b2cc834 --- /dev/null +++ b/src/Notebook/Test/NotebookTest.cxx @@ -0,0 +1,324 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "NotebookTest.hxx" +// +#include +// +#include +#include +#include +#include +// +using namespace std; +// +// ============================================================================ +/*! + * Set up the environment + */ +// ============================================================================ +void NotebookTest::setUp() +{ +} +// ============================================================================ +/*! + * - delete trace classes + */ +// ============================================================================ +void NotebookTest::tearDown() +{ +} +// ============================================================================ +/*! + * Check expressions with int values + */ +// ============================================================================ +void NotebookTest::testParameterInt() +{ + const int aNb=6; + bool bOk; + int j; + int aResult[aNb], aX; + RString aExp[aNb]; + RString aA, aB, aC; + SALOME_EvalVariant aRVR, aRVA, aRVC, aRVB; + SALOME_EvalVariantType aType; + SALOME_EvalExprError aErr; + // + aExp[0]="a+b"; + aExp[1]="(a+b)/7"; + aExp[2]="((a+b)/7)*10"; + aExp[3]="-((a+b)/7)+a*b/8"; + aExp[4]="-((a+c)/4+(-b-c)*2)/2"; + aExp[5]="a*(a*(a*(a*(a*(a+1)+1)+1)+1)+1)"; + // + aResult[0]=-7; + aResult[1]=-1; + aResult[2]=-10; + aResult[3]=0; + aResult[4]=5; + aResult[5]=6; + // + aA="a"; + aB="b"; + aC="c"; + // + aRVA=1; + aRVB=-8; + aRVC=15; + // + SALOME_EvalExpr aEvalExpr(aExp[0]); + // + SALOME_EvalParser* aParser=aEvalExpr.parser(); + // + aParser->setParameter(aA, aRVA); + aParser->setParameter(aB, aRVB); + aParser->setParameter(aC, aRVC); + // + for (j=0; jsetParameter(aA, aRVA); + aParser->setParameter(aB, aRVB); + aParser->setParameter(aC, aRVC); + // + for (j=0; jsetParameter(aA, aRVA); + aParser->setParameter(aB, aRVB); + aParser->setParameter(aC, aRVC); + aParser->setParameter(aD, aRVD); + // + for (j=0; jsetParameter(aA, aRVA); + aParser->setParameter(aB, aRVB); + aParser->setParameter(aC, aRVC); + aParser->setParameter(aD, aRVD); + // + for (j=0; j + +class NotebookTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( NotebookTest ); + CPPUNIT_TEST( testParameterInt ); + CPPUNIT_TEST( testParameterDouble ); + CPPUNIT_TEST( testParameterString ); + CPPUNIT_TEST( testParameterBoolean ); + CPPUNIT_TEST_SUITE_END(); + +public: + + void setUp(); + void tearDown(); + void testParameterInt(); + void testParameterDouble(); + void testParameterString(); + void testParameterBoolean(); +}; + +#endif diff --git a/src/Notebook/Test/TestNotebook.cxx b/src/Notebook/Test/TestNotebook.cxx new file mode 100644 index 000000000..8376ded60 --- /dev/null +++ b/src/Notebook/Test/TestNotebook.cxx @@ -0,0 +1,34 @@ + + +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// --- include all SALOMEDSImpl Test from basics until the present directory +// +#include "NotebookTest.hxx" + +// --- Registers the fixture into the 'registry' + +CPPUNIT_TEST_SUITE_REGISTRATION( NotebookTest ); + +// --- generic Main program from Basic/Test + +#include "BasicMainTest.hxx" -- 2.39.2