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

Bug in how standardUnitMultipliers is used in validator #525

Open
kerimoyle opened this issue Jan 22, 2020 · 0 comments
Open

Bug in how standardUnitMultipliers is used in validator #525

kerimoyle opened this issue Jan 22, 2020 · 0 comments

Comments

@kerimoyle
Copy link
Contributor

kerimoyle commented Jan 22, 2020

There's been a bug in how we test for multiplier mismatch where there are standardUnitMultipliers involved. This test below should return a warning because there are 1000L per m^3, but it was returning no mismatch. I'll put the super-quick fix in a new PR.

TEST(Validator, unitMultiplierFactorDifference)
{
    libcellml::ValidatorPtr validator = libcellml::Validator::create();
    libcellml::ModelPtr m = createModelTwoComponentsWithOneVariableEach("m", "c1", "c2", "v1", "v2");
    auto c1 = m->component(0);
    auto c2 = m->component(1);
    auto v1 = c1->variable(0);
    auto v2 = c2->variable(0);

    v1->setUnits("litre");

    libcellml::UnitsPtr u = libcellml::Units::create();
    u->setName("big_barrel");
    u->addUnit("metre", 3.0);
    m->addUnits(u);

    v2->setUnits(u);

    libcellml::Variable::addEquivalence(v1, v2); // litre ~= metre^3 // Nope: there are 1000L = 1m^3

    validator->validateModel(m);

    printIssues(validator);

    std::cout << "Issues: " << validator->issueCount() << std::endl;
    std::cout << "Errors: " << validator->errorCount() << std::endl;
    std::cout << "Warnings: " << validator->warningCount() << std::endl;
    std::cout << "Hints: " << validator->hintCount() << std::endl;

    EXPECT_EQ(size_t(1), validator->issueCount());  // << no issues reported, but there should have been
    EXPECT_EQ(size_t(0), validator->errorCount());
    EXPECT_EQ(size_t(1), validator->warningCount());

    EXPECT_EQ_ISSUES(expectedErrors, validator);
}
@kerimoyle kerimoyle changed the title Mismatched units between equivalent variables validation is incorrect? Ignore me Jan 22, 2020
@kerimoyle kerimoyle reopened this Jan 22, 2020
@kerimoyle kerimoyle changed the title Ignore me Bug in how standardUnitMultipliers is used in validator Jan 22, 2020
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