|
From: <mor...@us...> - 2008-11-07 09:29:32
|
Revision: 3280
http://ecell.svn.sourceforge.net/ecell/?rev=3280&view=rev
Author: moriyoshi
Date: 2008-11-07 09:29:29 +0000 (Fri, 07 Nov 2008)
Log Message:
-----------
* Throw exception in getSizeVariable() when no SIZE variable exists.
Modified Paths:
--------------
ecell3/branches/ecell-3.1/ecell/libecs/System.cpp
ecell3/branches/ecell-3.1/ecell/libecs/System.hpp
ecell3/branches/ecell-3.1/ecell/libecs/tests/Makefile.am
Added Paths:
-----------
ecell3/branches/ecell-3.1/ecell/libecs/tests/System_test.cpp
Modified: ecell3/branches/ecell-3.1/ecell/libecs/System.cpp
===================================================================
--- ecell3/branches/ecell-3.1/ecell/libecs/System.cpp 2008-11-07 09:01:08 UTC (rev 3279)
+++ ecell3/branches/ecell-3.1/ecell/libecs/System.cpp 2008-11-07 09:29:29 UTC (rev 3280)
@@ -320,6 +320,17 @@
{
}
+Variable const* const System::getSizeVariable() const
+{
+ if ( !theSizeVariable )
+ {
+ THROW_EXCEPTION( IllegalOperation,
+ "SIZE variable is not associated to "
+ + getFullID().getString() );
+ }
+ return theSizeVariable;
+}
+
const SystemPath System::getSystemPath() const
{
if( isRootSystem() )
Modified: ecell3/branches/ecell-3.1/ecell/libecs/System.hpp
===================================================================
--- ecell3/branches/ecell-3.1/ecell/libecs/System.hpp 2008-11-07 09:01:08 UTC (rev 3279)
+++ ecell3/branches/ecell-3.1/ecell/libecs/System.hpp 2008-11-07 09:29:29 UTC (rev 3280)
@@ -247,12 +247,8 @@
}
- VariableCptr const getSizeVariable() const
- {
- return theSizeVariable;
- }
+ VariableCptr const getSizeVariable() const;
-
void notifyChangeOfEntityList();
VariableCptr const findSizeVariable() const;
Modified: ecell3/branches/ecell-3.1/ecell/libecs/tests/Makefile.am
===================================================================
--- ecell3/branches/ecell-3.1/ecell/libecs/tests/Makefile.am 2008-11-07 09:01:08 UTC (rev 3279)
+++ ecell3/branches/ecell-3.1/ecell/libecs/tests/Makefile.am 2008-11-07 09:29:29 UTC (rev 3280)
@@ -32,4 +32,7 @@
check_PROGRAMS += Polymorph_test
Polymorph_test_SOURCES = Polymorph_test.cpp
+check_PROGRAMS += System_test
+System_test_SOURCES = System_test.cpp
+
TESTS=$(check_PROGRAMS)
Added: ecell3/branches/ecell-3.1/ecell/libecs/tests/System_test.cpp
===================================================================
--- ecell3/branches/ecell-3.1/ecell/libecs/tests/System_test.cpp (rev 0)
+++ ecell3/branches/ecell-3.1/ecell/libecs/tests/System_test.cpp 2008-11-07 09:29:29 UTC (rev 3280)
@@ -0,0 +1,79 @@
+//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+//
+// This file is part of the E-Cell System
+//
+// Copyright (C) 1996-2008 Keio University
+// Copyright (C) 2005-2008 The Molecular Sciences Institute
+//
+//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+//
+//
+// E-Cell System is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// E-Cell System 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with E-Cell System -- see the file COPYING.
+// If not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//END_HEADER
+//
+// written by Koichi Takahashi
+// modified by Moriyoshi Koizumi
+//
+
+#define BOOST_TEST_MODULE "System"
+
+#include <boost/mpl/list.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_suite.hpp>
+#include <boost/test/test_case_template.hpp>
+#include <boost/preprocessor/stringize.hpp>
+
+#include "System.hpp"
+#include "Variable.hpp"
+#include "Exceptions.hpp"
+#include "dmtool/ModuleMaker.hpp"
+#include "dmtool/DMObject.hpp"
+
+#include <iostream>
+
+BOOST_AUTO_TEST_CASE(testInstantiation)
+{
+ using namespace libecs;
+
+ StaticModuleMaker< EcsObject > mmaker;
+ DM_NEW_STATIC( &mmaker, EcsObject, System );
+
+ System* sys = reinterpret_cast< System * >( mmaker.getModule( "System" ).getAllocator()() );
+ BOOST_CHECK(sys);
+ BOOST_CHECK_EQUAL("System", sys->getPropertyInterface().getClassName());
+}
+
+BOOST_AUTO_TEST_CASE(testGetSizeVariable)
+{
+ using namespace libecs;
+
+ StaticModuleMaker< EcsObject > mmaker;
+ DM_NEW_STATIC( &mmaker, EcsObject, System );
+ DM_NEW_STATIC( &mmaker, EcsObject, Variable );
+
+ System* sys = reinterpret_cast< System * >( mmaker.getModule( "System" ).getAllocator()() );
+ BOOST_CHECK_THROW( sys->getSizeVariable(), IllegalOperation );
+
+ Variable* var = reinterpret_cast< Variable * >( mmaker.getModule( "Variable" ).getAllocator()() );
+ var->setValue( 123.0 );
+ var->setID( "SIZE" );
+ sys->registerVariable( var );
+ sys->configureSizeVariable();
+
+ BOOST_CHECK( sys->getSizeVariable() );
+ BOOST_CHECK_EQUAL( 123.0, sys->getSize() );
+};
Property changes on: ecell3/branches/ecell-3.1/ecell/libecs/tests/System_test.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|