|
From: <sar...@us...> - 2014-09-27 12:23:57
|
Revision: 21163
http://sourceforge.net/p/sbml/code/21163
Author: sarahkeating
Date: 2014-09-27 12:23:47 +0000 (Sat, 27 Sep 2014)
Log Message:
-----------
Merged revision(s) 21155-21161 from trunk/libsbml:
Modified Paths:
--------------
branches/libsbml-experimental/CMakeLists.txt
branches/libsbml-experimental/NEWS.txt
branches/libsbml-experimental/src/sbml/SBase.cpp
branches/libsbml-experimental/src/sbml/SBase.h
branches/libsbml-experimental/src/sbml/packages/comp/sbml/Submodel.cpp
branches/libsbml-experimental/src/sbml/packages/comp/util/CompFlatteningConverter.cpp
branches/libsbml-experimental/src/sbml/packages/comp/util/CompFlatteningConverter.h
branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestRunner.c
branches/libsbml-experimental/src/sbml/test/TestSBMLDocument.c
Added Paths:
-----------
branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestCompFlatteningConverterStripPackage.cpp
branches/libsbml-experimental/src/sbml/packages/comp/util/test/test-data/test_external_flat_strip/
Property Changed:
----------------
branches/libsbml-experimental/
Index: branches/libsbml-experimental
===================================================================
--- branches/libsbml-experimental 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental 2014-09-27 12:23:47 UTC (rev 21163)
Property changes on: branches/libsbml-experimental
___________________________________________________________________
Modified: svn:mergeinfo
## -2,4 +2,4 ##
/branches/libsbml-4:9056-10118
/branches/libsbml-5-conversion:14155-14227
/branches/libsbml-ast-plugin:16251-19654
-/trunk/libsbml:18168-18171,18174-18194,18196-18201,18204,18207-18209,18211-18213,18215-18216,18226,18228-18292,18294-18388,18390-18443,18450-18454,18456-18458,18460-18462,18464,18466,18469-18520,18523-18561,18563,18565-18584,18586-18638,18640-18641,18644-18715,18717-18844,18846-19128,19130-19829,19831-21154
+/trunk/libsbml:18168-18171,18174-18194,18196-18201,18204,18207-18209,18211-18213,18215-18216,18226,18228-18292,18294-18388,18390-18443,18450-18454,18456-18458,18460-18462,18464,18466,18469-18520,18523-18561,18563,18565-18584,18586-18638,18640-18641,18644-18715,18717-18844,18846-19128,19130-19829,19831-21161
\ No newline at end of property
Modified: branches/libsbml-experimental/CMakeLists.txt
===================================================================
--- branches/libsbml-experimental/CMakeLists.txt 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental/CMakeLists.txt 2014-09-27 12:23:47 UTC (rev 21163)
@@ -805,10 +805,27 @@
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
+
endforeach(flag_var)
add_definitions( -D_MT)
endif(WITH_STATIC_RUNTIME)
+ # CMake no longer creates PDB files for static libraries after 2.8.11
+ # so we store debug information in the object files instead
+ if (${CMAKE_VERSION} VERSION_GREATER "2.8.11")
+ foreach(flag_var
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
+
+ if(${flag_var} MATCHES "/Zi")
+ STRING(REPLACE "/Zi" "/Z7" "${flag_var}" "${${flag_var}}")
+ endif(${flag_var} MATCHES "/Zi")
+
+ endforeach(flag_var)
+ endif()
+
file(GLOB WIN32_BINARIES ${LIBSBML_DEPENDENCY_DIR}/bin/*.dll)
INSTALL(FILES ${WIN32_BINARIES} DESTINATION bin)
file(GLOB WIN32_DEPENDENCIES ${LIBSBML_DEPENDENCY_DIR}/lib/*.lib)
Modified: branches/libsbml-experimental/NEWS.txt
===================================================================
--- branches/libsbml-experimental/NEWS.txt 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental/NEWS.txt 2014-09-27 12:23:47 UTC (rev 21163)
@@ -8,10 +8,21 @@
STABLE RELEASE
* New features
+
+ - There is now an interface for JavaScript. This has been tested
+ on all platforms. Building requires SWIG version 3.0.2 or greater
+ and depends on node-gyp. Feedback on this would be greatly
+ appreciated.
- The facility of using the data members of objects as attributes
in python has been extended to work with Python version 3.
-
+
+ - The SBMLDocument class now has an 'isSetModel()' function.
+
+ - There is a new writSBMLToStdString() function that returns a
+ std::string rather than a const char *. This facilitates cleaner
+ memory management.
+
- 'comp' package-specific updates:
- 'fbc' package-specific updates:
- 'layout' package-specific updates:
@@ -72,6 +83,10 @@
* New features
+ Code for the Dynamic Structures ('dyn') package has been added.
+ This reflects the draft specification dated August 8 2014.
+
+
- 'arrays' package-specific updates:
- 'distrib' package-specific updates:
- 'groups' package-specific updates:
@@ -96,7 +111,9 @@
Thanks to Gerard Weatherby for reporting it.
- 'spatial' package-specific bug fixes:
-
+
+ - The spatial code has been updated in line with the specification
+ Release 0.88 dated September 2014.
====================================================================
5.10.2 (2014-07-17)
Modified: branches/libsbml-experimental/src/sbml/SBase.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/SBase.cpp 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental/src/sbml/SBase.cpp 2014-09-27 12:23:47 UTC (rev 21163)
@@ -3020,6 +3020,14 @@
}
+SBasePlugin*
+SBase::getDisabledPlugin(unsigned int n)
+{
+ if (n>=getNumDisabledPlugins()) return NULL;
+ return mDisabledPlugins[n];
+}
+
+
/*
* Returns a plugin object (extenstion interface) of package extension
* with the given package name or URI.
@@ -3036,6 +3044,13 @@
}
+const SBasePlugin*
+SBase::getDisabledPlugin(unsigned int n) const
+{
+ return const_cast<SBase*>(this)->getDisabledPlugin(n);
+}
+
+
/*
* Returns the number of plugin objects of package extensions.
*
Modified: branches/libsbml-experimental/src/sbml/SBase.h
===================================================================
--- branches/libsbml-experimental/src/sbml/SBase.h 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental/src/sbml/SBase.h 2014-09-27 12:23:47 UTC (rev 21163)
@@ -2658,6 +2658,40 @@
/**
+ * Returns the nth disabled plug-in object (extension interface) for an SBML Level 3
+ * package extension.
+ *
+ * @copydetails doc_what_are_plugins
+ *
+ * @param n the index of the disabled plug-in to return
+ *
+ * @return the nth disabled plug-in object (the libSBML extension interface) of a
+ * package extension.
+ *
+ * @see getNumDisabledPlugins()
+ * @see getPlugin(@if java String@else const std::string& package@endif)
+ */
+ SBasePlugin* getDisabledPlugin(unsigned int n);
+
+
+ /**
+ * Returns the nth disabled plug-in object (extension interface) for an SBML Level 3
+ * package extension.
+ *
+ * @copydetails doc_what_are_plugins
+ *
+ * @param n the index of the disabled plug-in to return
+ *
+ * @return the nth disabled plug-in object (the libSBML extension interface) of a
+ * package extension.
+ *
+ * @see getNumDisabledPlugins()
+ * @see getPlugin(@if java String@else const std::string& package@endif)
+ */
+ const SBasePlugin* getDisabledPlugin(unsigned int n) const;
+
+
+ /**
* Returns the number of plug-in objects (extenstion interfaces) for SBML
* Level 3 package extensions known.
*
Modified: branches/libsbml-experimental/src/sbml/packages/comp/sbml/Submodel.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/packages/comp/sbml/Submodel.cpp 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental/src/sbml/packages/comp/sbml/Submodel.cpp 2014-09-27 12:23:47 UTC (rev 21163)
@@ -922,20 +922,26 @@
mInstantiatedModel->connectToParent(this);
mInstantiatedModel->setSBMLDocument(origdoc);
mInstantiatedModel->enablePackage(getPackageURI(), getPrefix(), true);
+ CompModelPlugin* instmodplug =
+ static_cast<CompModelPlugin*>(mInstantiatedModel->getPlugin(getPrefix()));
+ if (instmodplug == NULL)
+ {
+ mInstantiatedModel->enablePackageInternal(getPackageURI(), getPrefix(), true);
+ }
- // enable any packages that were enabled on the doc
- //for (unsigned int n = 0; n < origdoc->getNumPlugins(); n++)
- //{
- // SBasePlugin * plugin = origdoc->getPlugin(n);
- //
- // mInstantiatedModel->enablePackage(plugin->getURI(),
- // plugin->getPrefix(), true);
- //}
+ // disable any packages that were disabled on the rootdoc
+ for (unsigned int n = 0; n < rootdoc->getNumDisabledPlugins(); n++)
+ {
+ SBasePlugin * plugin = rootdoc->getDisabledPlugin(n);
+
+ mInstantiatedModel->enablePackageInternal(plugin->getURI(),
+ plugin->getPrefix(), false);
+ }
CompModelPlugin* origmodplug =
static_cast<CompModelPlugin*>(rootdoc->getModel()->getPlugin(getPrefix()));
- CompModelPlugin* instmodplug =
+ instmodplug =
static_cast<CompModelPlugin*>(mInstantiatedModel->getPlugin(getPrefix()));
if (instmodplug == NULL)
Modified: branches/libsbml-experimental/src/sbml/packages/comp/util/CompFlatteningConverter.cpp
===================================================================
--- branches/libsbml-experimental/src/sbml/packages/comp/util/CompFlatteningConverter.cpp 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental/src/sbml/packages/comp/util/CompFlatteningConverter.cpp 2014-09-27 12:23:47 UTC (rev 21163)
@@ -39,6 +39,7 @@
#include <sbml/packages/comp/common/CompExtensionTypes.h>
#include <sbml/SBMLWriter.h>
#include <sbml/SBMLReader.h>
+#include <sbml/util/IdList.h>
#ifdef __cplusplus
@@ -111,6 +112,8 @@
"specify whether to abort if any unflattenable packages are encountered");
prop.addOption("stripUnflattenablePackages", true,
"specify whether to strip any unflattenable packages ignored by 'abortIfUnflattenable'");
+ prop.addOption("stripPackages", "",
+ "comma separated list of packages to be stripped before flattening is attempted");
return prop;
}
@@ -149,7 +152,14 @@
return LIBSBML_OPERATION_SUCCESS;
}
- // look at the document and work out the status of any packages
+ // strip packages as instructed by user
+ int success = stripPackages();
+ if (success != LIBSBML_OPERATION_SUCCESS)
+ {
+ return LIBSBML_OPERATION_FAILED;
+ }
+
+ // look at the document and work out the status of any remaining packages
mPackageValues.clear();
analyseDocument();
@@ -639,6 +649,27 @@
}
+const std::string&
+CompFlatteningConverter::getPackagesToStrip() const
+{
+ static std::string empty = "";
+
+ if (getProperties() == NULL)
+ {
+ return empty;
+ }
+ else if (getProperties()->hasOption("stripPackages") == false)
+ {
+ return empty;
+ }
+ else
+ {
+ return getProperties()->getValue("stripPackages");
+ }
+}
+
+
+
void
CompFlatteningConverter::stripUnflattenablePackages()
{
@@ -723,6 +754,53 @@
}
}
+int
+CompFlatteningConverter::stripPackages()
+{
+ IdList pkgsToStrip(getPackagesToStrip());
+
+ unsigned int num = pkgsToStrip.size();
+
+ if (num == 0)
+ {
+ return LIBSBML_OPERATION_SUCCESS;
+ }
+
+ XMLNamespaces *ns = mDocument->getSBMLNamespaces()->getNamespaces();
+ for (int i = 0; i < ns->getLength(); i++)
+ {
+ std::string nsURI = ns->getURI(i);
+ std::string package = ns->getPrefix(i);
+ if (package.empty() == true)
+ {
+ continue;
+ }
+ else if (pkgsToStrip.contains(package) == true)
+ {
+ mDocument->enablePackage(nsURI, package, false);
+ mDisabledPackages.insert(make_pair(nsURI, package));
+ }
+ }
+
+ unsigned int count = 0;
+ for (unsigned int i = 0; i < num; i++)
+ {
+ if (mDocument->isPackageEnabled(pkgsToStrip.at(i)) == false)
+ {
+ count++;
+ }
+ }
+
+ if (num == count)
+ {
+ return LIBSBML_OPERATION_SUCCESS;
+ }
+ else
+ {
+ return LIBSBML_OPERATION_FAILED;
+ }
+}
+
bool
CompFlatteningConverter::canBeFlattened()
{
Modified: branches/libsbml-experimental/src/sbml/packages/comp/util/CompFlatteningConverter.h
===================================================================
--- branches/libsbml-experimental/src/sbml/packages/comp/util/CompFlatteningConverter.h 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental/src/sbml/packages/comp/util/CompFlatteningConverter.h 2014-09-27 12:23:47 UTC (rev 21163)
@@ -254,6 +254,8 @@
private:
+ int stripPackages();
+
int reconstructDocument(Model* flatmodel);
int reconstructDocument(Model* flatmodel,
@@ -277,6 +279,8 @@
bool getAbortForNone() const;
+ const std::string& getPackagesToStrip() const;
+
bool canBeFlattened();
void restoreNamespaces();
Copied: branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestCompFlatteningConverterStripPackage.cpp (from rev 21161, trunk/libsbml/src/sbml/packages/comp/util/test/TestCompFlatteningConverterStripPackage.cpp)
===================================================================
--- branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestCompFlatteningConverterStripPackage.cpp (rev 0)
+++ branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestCompFlatteningConverterStripPackage.cpp 2014-09-27 12:23:47 UTC (rev 21163)
@@ -0,0 +1,572 @@
+/**
+ * \file TestCompFlatteningConverterStripPackage.cpp
+ * \brief Implementation of the Tests for the Comp flattening converter
+ * \author Frank T. Bergmann
+ *
+ * <!--------------------------------------------------------------------------
+ * This file is part of libSBML. Please visit http://sbml.org for more
+ * information about SBML, and the latest version of libSBML.
+ *
+ * Copyright (C) 2013-2014 jointly by the following organizations:
+ * 1. California Institute of Technology, Pasadena, CA, USA
+ * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
+ * 3. University of Heidelberg, Heidelberg, Germany
+ *
+ * Copyright 2011-2012 jointly by the following organizations:
+ * 1. California Institute of Technology, Pasadena, CA, USA
+ * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
+ *
+ * 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. A copy of the license agreement is provided
+ * in the file named "LICENSE.txt" included with this software distribution
+ * and also available online as http://sbml.org/software/libsbml/license.html
+ * ---------------------------------------------------------------------- -->*/
+
+#include <sbml/common/common.h>
+
+#include <sbml/packages/comp/common/CompExtensionTypes.h>
+
+#include <sbml/conversion/SBMLConverterRegistry.h>
+#include <sbml/SBMLReader.h>
+#include <sbml/SBMLTypes.h>
+
+#include <string>
+
+#include <check.h>
+
+using namespace std;
+
+LIBSBML_CPP_NAMESPACE_USE
+
+
+std::string writeSBMLToStringSafe1(const SBMLDocument* doc)
+{
+ char* modelC = writeSBMLToString(doc);
+ std::string model(modelC);
+ free(modelC);
+ return model;
+}
+
+
+BEGIN_C_DECLS
+
+extern char *TestDataDirectory;
+
+void TestPair(std::string file1, std::string file2, std::string pkgToStrip,
+ unsigned int numErrors = 0)
+{
+ std::string filename(TestDataDirectory);
+ std::string dir("test_external_flat_strip/");
+
+ ConversionProperties props;
+
+ props.addOption("flatten comp");
+ props.addOption("basePath", filename);
+ props.addOption("performValidation", true);
+ props.addOption("stripPackages", pkgToStrip);
+ props.addOption("abortIfUnflattenable", "none");
+
+ SBMLConverter* converter = SBMLConverterRegistry::getInstance().
+ getConverterFor(props);
+
+ // load document
+ std::string cfile = filename + dir + file1;
+ SBMLDocument* doc = readSBMLFromFile(cfile.c_str());
+
+ // fail if there is no model (readSBMLFromFile always returns a valid doc)
+ fail_unless(doc->getModel() != NULL);
+
+ fail_unless(doc->getErrorLog()->getNumFailsWithSeverity(LIBSBML_SEV_ERROR)
+ == numErrors);
+
+ converter->setDocument(doc);
+ int result = converter->convert();
+
+ // fail if conversion was not valid
+ fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+
+ std::string newModel = writeSBMLToStringSafe1(doc);
+
+ std::string ffile = filename + dir + file2;
+ SBMLDocument* fdoc = readSBMLFromFile(ffile.c_str());
+ std::string flatModel = writeSBMLToStringSafe1(fdoc);
+
+ fail_unless(flatModel == newModel);
+
+ delete doc;
+ delete fdoc;
+ delete converter;
+}
+
+
+void TestPairDiffDir(std::string file1, std::string file2,
+ std::string pkgToStrip,
+ unsigned int numErrors = 0)
+{
+ std::string filename(TestDataDirectory);
+
+ ConversionProperties props;
+
+ props.addOption("flatten comp");
+ props.addOption("basePath", filename);
+ props.addOption("performValidation", true);
+ props.addOption("stripPackages", pkgToStrip);
+ props.addOption("abortIfUnflattenable", "none");
+
+ SBMLConverter* converter = SBMLConverterRegistry::getInstance().
+ getConverterFor(props);
+
+ // load document
+ std::string cfile = filename + file1;
+ SBMLDocument* doc = readSBMLFromFile(cfile.c_str());
+
+ // fail if there is no model (readSBMLFromFile always returns a valid doc)
+ fail_unless(doc->getModel() != NULL);
+
+ fail_unless(doc->getErrorLog()->getNumFailsWithSeverity(LIBSBML_SEV_ERROR)
+ == numErrors);
+
+ converter->setDocument(doc);
+ int result = converter->convert();
+
+ // fail if conversion was not valid
+ fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+
+ std::string newModel = writeSBMLToStringSafe1(doc);
+
+ std::string ffile = filename + file2;
+ SBMLDocument* fdoc = readSBMLFromFile(ffile.c_str());
+ std::string flatModel = writeSBMLToStringSafe1(fdoc);
+
+ fail_unless(flatModel == newModel);
+
+ delete doc;
+ delete fdoc;
+ delete converter;
+}
+
+
+START_TEST (test_comp_flatten_strip_fbc_submodels)
+{
+ // fbc in modeldefinitions within one doc
+ if (SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPairDiffDir("aggregate_fbc2.xml",
+ "aggregate_fbc2_flat_fbc_removed.xml", "fbc");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_submodels_1)
+{
+ // fbc in modeldefinitions within one doc
+ if (SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPairDiffDir("aggregate_fbc2.xml", "aggregate_fbc2_flat.xml", "");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_external)
+{
+ // fbc in main doc and external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_in_external.xml",
+ "fbc_in_external_flat_fbc_removed.xml", "fbc");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_external_1)
+{
+ // fbc in main doc and external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_in_external.xml", "fbc_in_external_flat.xml", "");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_external_2)
+{
+ // fbc not in main doc but only in external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_in_external_only.xml",
+ "fbc_in_external_flat_fbc_removed.xml", "fbc");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_external_3)
+{
+ // fbc not in main doc but only in external doc
+ // flat doc should declare fbc
+ if (SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_in_external_only.xml",
+ "fbc_in_external_flat_fbc_added.xml", "");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_external_4)
+{
+ // comp in main doc not in external; fbc in both
+ if (SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_in_external_no_comp.xml",
+ "fbc_in_external_flat_fbc_removed.xml", "fbc");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_layout_submodels)
+{
+ // layout in modeldefinitions within one doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true)
+ {
+ TestPair("layout_in_submodels.xml",
+ "layout_in_submodels_flat_layout_removed.xml", "layout");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_layout_submodels_1)
+{
+ // layout in modeldefinitions within one doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true)
+ {
+ TestPairDiffDir("aggregate_layout.xml",
+ "aggregate_layout_flat_layout_removed.xml", "layout");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_layout_external)
+{
+ // layout in main doc and external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true)
+ {
+ TestPair("layout_in_external.xml",
+ "layout_in_external_flat_layout_removed.xml", "layout");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_layout_external_1)
+{
+ // layout in main doc and external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true)
+ {
+ TestPair("layout_in_external.xml", "layout_in_external_flat.xml", "");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_layout_external_2)
+{
+ // layout not in main doc but only in external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true)
+ {
+ TestPair("layout_in_external_only.xml",
+ "layout_in_external_flat_layout_removed.xml", "layout");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_layout_external_3)
+{
+ // layout not in main doc but only in external doc
+ // flat doc should declare layout
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true)
+ {
+ TestPair("layout_in_external_only.xml",
+ "layout_in_external_flat_layout_added.xml", "");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_layout_external_4)
+{
+ // comp in main doc not in external; layout in both
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true)
+ {
+ TestPair("layout_in_external_no_comp.xml",
+ "layout_in_external_flat_layout_removed.xml", "layout");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_unreq_unknown_submodels)
+{
+ // unknown unrequired package in modeldefinitions within one doc
+ TestPairDiffDir("unknown9.xml", "unknown9_flat.xml", "");
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_unreq_unknown_external)
+{
+ // unknown unrequired in main doc and external doc
+ TestPair("unreq_unknown_in_external.xml", "unreq_unknown_in_external_flat_unknown_removed.xml", "extra");
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_unreq_unknown_external_1)
+{
+ // unknown unrequired in main doc and external doc
+ TestPair("unreq_unknown_in_external.xml", "unreq_unknown_in_external_flat_unknown_removed.xml", "");
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_unreq_unknown_external_2)
+{
+ // unknown unrequired not in main doc but only in external doc
+ TestPair("unreq_unknown_in_external_only.xml", "unreq_unknown_in_external_flat_unknown_removed.xml", "extra");
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_unreq_unknown_external_3)
+{
+ // unknown unrequired not in main doc but only in external doc
+ TestPair("unreq_unknown_in_external_only.xml", "unreq_unknown_in_external_flat_unknown_removed.xml", "");
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_unreq_unknown_external_4)
+{
+ // comp in main doc not in external; unknown unrequired in both
+ TestPair("unreq_unknown_in_external_no_comp.xml", "unreq_unknown_in_external_flat_unknown_removed.xml", "extra");
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_req_unknown_submodels)
+{
+ // unknown required package in modeldefinitions within one doc
+ TestPairDiffDir("unknown10.xml", "unknown10_flat.xml", "", 1);
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_req_unknown_external)
+{
+ // unknown required in main doc and external doc
+ TestPair("req_unknown_in_external.xml", "req_unknown_in_external_flat_unknown_removed.xml", "extra", 1);
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_req_unknown_external_1)
+{
+ // unknown required in main doc and external doc
+ TestPair("req_unknown_in_external.xml", "req_unknown_in_external_flat_unknown_removed.xml", "", 1);
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_req_unknown_external_2)
+{
+ // unknown required not in main doc but only in external doc
+ TestPair("req_unknown_in_external_only.xml", "req_unknown_in_external_flat_unknown_removed.xml", "extra");
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_req_unknown_external_3)
+{
+ // unknown required not in main doc but only in external doc
+ TestPair("req_unknown_in_external_only.xml", "req_unknown_in_external_flat_unknown_removed.xml", "");
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_req_unknown_external_4)
+{
+ // comp in main doc not in external; unknown required in both
+ TestPair("req_unknown_in_external_no_comp.xml", "req_unknown_in_external_flat_unknown_removed.xml", "extra", 1);
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_layout_external)
+{
+ // fbc and layout in main doc and external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true
+ && SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_layout_in_external.xml",
+ "fbc_layout_in_external_flat_both_removed.xml", "layout, fbc");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_layout_external_1)
+{
+ // fbc and layout in main doc and external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true
+ && SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_layout_in_external.xml",
+ "fbc_layout_in_external_flat_both_removed.xml", "fbc, layout");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_layout_external_2)
+{
+ // fbc and layout in main doc and external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true
+ && SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_layout_in_external.xml",
+ "fbc_layout_in_external_flat_fbc_removed.xml", "fbc");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_layout_external_3)
+{
+ // fbc and layout in main doc and external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true
+ && SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_layout_in_external.xml",
+ "fbc_layout_in_external_flat_layout_removed.xml", "layout");
+ }
+}
+END_TEST
+
+
+START_TEST (test_comp_flatten_strip_fbc_layout_external_4)
+{
+ // fbc and layout in main doc and external doc
+ if (SBMLExtensionRegistry::isPackageEnabled("layout") == true
+ && SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
+ {
+ TestPair("fbc_layout_in_external.xml",
+ "fbc_layout_in_external_flat.xml", "");
+ }
+}
+END_TEST
+
+
+Suite *
+create_suite_TestFlatteningConverterStripPackage (void)
+{
+ TCase *tcase = tcase_create("SBMLCompFlatteningConverterStripPackage");
+ Suite *suite = suite_create("SBMLCompFlatteningConverterStripPackage");
+
+ // fbc in modeldefinitions within one doc
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_submodels);
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_submodels_1);
+
+ // fbc in main doc and external doc
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_external);
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_external_1);
+
+ // fbc not in main doc but only in external doc
+ // FAILS - fbc not removed from external references
+ //tcase_add_test(tcase, test_comp_flatten_strip_fbc_external_2);
+
+ // fbc not in main doc but only in external doc
+ // flat doc should declare fbc
+ // FAILS - fbc not declared on flat doc
+ //tcase_add_test(tcase, test_comp_flatten_strip_fbc_external_3);
+
+ // comp in main doc not in external; fbc in both
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_external_4);
+
+ // layout in modeldefinitions within one doc
+ tcase_add_test(tcase, test_comp_flatten_strip_layout_submodels);
+ tcase_add_test(tcase, test_comp_flatten_strip_layout_submodels_1);
+
+ // layout in main doc and external doc
+ tcase_add_test(tcase, test_comp_flatten_strip_layout_external);
+ tcase_add_test(tcase, test_comp_flatten_strip_layout_external_1);
+
+ // layout not in main doc but only in external doc
+ tcase_add_test(tcase, test_comp_flatten_strip_layout_external_2);
+
+ // layout not in main doc but only in external doc
+ // flat doc should declare layout
+ // FAILS - layout not declared on flat doc
+ //tcase_add_test(tcase, test_comp_flatten_strip_layout_external_3);
+
+ // comp in main doc not in external; layout in both
+ tcase_add_test(tcase, test_comp_flatten_strip_layout_external_4);
+
+ // unknown unrequired package in modeldefinitions within one doc
+ tcase_add_test(tcase, test_comp_flatten_strip_unreq_unknown_submodels);
+
+ // unknown unrequired in main doc and external doc
+ tcase_add_test(tcase, test_comp_flatten_strip_unreq_unknown_external);
+ tcase_add_test(tcase, test_comp_flatten_strip_unreq_unknown_external_1);
+
+ // unknown unrequired not in main doc but only in external doc
+ tcase_add_test(tcase, test_comp_flatten_strip_unreq_unknown_external_2);
+
+ // unknown unrequired not in main doc but only in external doc
+ tcase_add_test(tcase, test_comp_flatten_strip_unreq_unknown_external_3);
+
+ // comp in main doc not in external; unknown unrequired in both
+ tcase_add_test(tcase, test_comp_flatten_strip_unreq_unknown_external_4);
+
+ // unknown required package in modeldefinitions within one doc
+ tcase_add_test(tcase, test_comp_flatten_strip_req_unknown_submodels);
+
+ // unknown required in main doc and external doc
+ tcase_add_test(tcase, test_comp_flatten_strip_req_unknown_external);
+ tcase_add_test(tcase, test_comp_flatten_strip_req_unknown_external_1);
+
+ // unknown required not in main doc but only in external doc
+ // FAILS conversion
+ //tcase_add_test(tcase, test_comp_flatten_strip_req_unknown_external_2);
+
+ // unknown required not in main doc but only in external doc
+ // FAILS conversion
+ //tcase_add_test(tcase, test_comp_flatten_strip_req_unknown_external_3);
+
+ // comp in main doc not in external; unknown required in both
+ tcase_add_test(tcase, test_comp_flatten_strip_req_unknown_external_4);
+
+ // fbc and layout in main doc and external doc
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_layout_external);
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_layout_external_1);
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_layout_external_2);
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_layout_external_3);
+ tcase_add_test(tcase, test_comp_flatten_strip_fbc_layout_external_4);
+
+
+ suite_add_tcase(suite, tcase);
+
+ return suite;
+}
+
+
+END_C_DECLS
+
Modified: branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestRunner.c
===================================================================
--- branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestRunner.c 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental/src/sbml/packages/comp/util/test/TestRunner.c 2014-09-27 12:23:47 UTC (rev 21163)
@@ -121,6 +121,7 @@
Suite *create_suite_TestURIResolvers (void);
Suite *create_suite_TestExternalModelResolving (void);
Suite *create_suite_TestCompFlatteningNewFlags (void);
+Suite *create_suite_TestFlatteningConverterStripPackage (void);
/**
* Global.
@@ -171,6 +172,7 @@
srunner_add_suite( runner, create_suite_TestFlatteningConverter() );
srunner_add_suite( runner, create_suite_TestExternalModelResolving() );
srunner_add_suite( runner, create_suite_TestCompFlatteningNewFlags() );
+ srunner_add_suite( runner, create_suite_TestFlatteningConverterStripPackage() );
/* srunner_set_fork_status(runner, CK_NOFORK); */
Modified: branches/libsbml-experimental/src/sbml/test/TestSBMLDocument.c
===================================================================
--- branches/libsbml-experimental/src/sbml/test/TestSBMLDocument.c 2014-09-27 12:12:15 UTC (rev 21162)
+++ branches/libsbml-experimental/src/sbml/test/TestSBMLDocument.c 2014-09-27 12:23:47 UTC (rev 21163)
@@ -66,6 +66,8 @@
fail_unless( SBMLDocument_getNumErrors (d) == 0 );
+ fail_unless( SBMLDocument_isSetModel(d) == 0 );
+
SBMLDocument_free(d);
}
END_TEST
@@ -85,6 +87,8 @@
fail_unless( SBMLDocument_getNumErrors (d) == 0 );
+ fail_unless( SBMLDocument_isSetModel(d) == 0 );
+
SBMLDocument_free(d);
}
END_TEST
@@ -105,12 +109,14 @@
Model_t *mout;
fail_unless(SBMLDocument_getModel(d) == NULL);
+ fail_unless( SBMLDocument_isSetModel(d) == 0 );
int i = SBMLDocument_setModel(d, m1);
fail_unless ( i == LIBSBML_OPERATION_SUCCESS );
mout = SBMLDocument_getModel(d);
fail_unless(mout != NULL);
fail_unless(mout != m1);
+ fail_unless( SBMLDocument_isSetModel(d) == 1 );
/* Reflexive case (pathological) */
i = SBMLDocument_setModel(d, SBMLDocument_getModel(d));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|