libcellml icon indicating copy to clipboard operation
libcellml copied to clipboard

Should adding a units/component to an import source also add to the model?

Open kerimoyle opened this issue 4 years ago • 0 comments

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.
}

kerimoyle avatar Sep 23 '20 04:09 kerimoyle