libcellml
libcellml copied to clipboard
Should adding a units/component to an import source also add to the model?
Would you expect adding a Units
to an ImportSource
which already belongs to a Model
would also add the Units
to the Model
?
TEST(ImportSource, addToImportSourceAlsoAddsToModel)
{
auto m = libcellml::Model::create("m1");
auto imp = libcellml::ImportSource::create();
// Add import source to model.
EXPECT_TRUE(m->addImportSource(imp));
EXPECT_EQ(m, imp->parent());
// Create units
auto u = libcellml::Units::create("u");
// Add to import source (cf the other way around).
imp->addUnits(u);
EXPECT_TRUE(u->isImport());
EXPECT_EQ(m, u->parent()); // fails currently, u had no parent.
}