Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hasUnits() test case (removed from discussion in 514) #522

Open
kerimoyle opened this issue Jan 15, 2020 · 1 comment
Open

hasUnits() test case (removed from discussion in 514) #522

kerimoyle opened this issue Jan 15, 2020 · 1 comment

Comments

@kerimoyle
Copy link
Contributor

Something new and hinky is happening in the validator ... here's a test to show you what I mean:
The test fails because the units defined inside the parsed model aren't being found when checking the variables inside the manually-created component, giving the message:

Description: Variable 't' has a units reference 'millisecond' that does not correspond with a standard units and is not a units defined in the variable's model.
There are a couple of things here:

  • the error message needs to also report the name of its parent component so we can find it more easily
  • if we're going to stick with "units" as a singular noun, how about this for the message:
    "Variable 't' in component 'whatever' has units of 'millisecond' which are neither standard nor defined within its model." (just to avoid the awkward "a units" sentences!)
    but the main thing is ...
  • the error shouldn't be happening as the units are defined in the model ... or am I missing something dumb?

TEST(Validator, unfoundUnitsInParsedModel)
{
    auto parser = libcellml::Parser::create();
    auto validator = libcellml::Validator::create();

    std::string in = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                     "<model xmlns=\"http:https://www.cellml.org/cellml/2.0#\" name=\"error_in_units\">"
                     "  <units name=\"millisecond\">"
                     "    <unit prefix=\"milli\" units=\"second\"/>"
                     "  </units>"
                     "  <component name=\"IonChannel\">"
                     "    <variable name=\"t\" units=\"millisecond\"/>"
                     "  </component>"
                     "</model>";

    auto model = parser->parseModel(in);

    validator->validateModel(model);
    EXPECT_EQ(size_t(0), validator->errorCount()); // <<< this is fine!

    // Add a component to represent the voltage dependency of the n-gate
    auto nGate = libcellml::Component::create("nGate");
    model->addComponent(nGate);

    auto t2 = libcellml::Variable::create("t2");
    t2->setUnits("millisecond");
    nGate->addVariable(t2);

    validator->validateModel(model);
    EXPECT_EQ(size_t(0), validator->errorCount()); // <<< test fails!
}
@kerimoyle
Copy link
Contributor Author

This is demonstrated in #516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant