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

Unit attribute verification #32

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

filip-stenstrom
Copy link
Collaborator

@filip-stenstrom filip-stenstrom commented Mar 31, 2023

Remaining work: FMI3 (not fixing for FMI1), and maybe more.

From Checker issue: modelica-tools/FMUComplianceChecker#19

I didn't understand why we would need dynamic creation of new units,
except for when the FMU had invalid XML and we wanted to still be able
to run without "errors" (if the model needs to be converted with respect
to base units, the model is invalid though), so removed it. I can revert
this if found too strict.

fmil_test.c is not the best name for the test util, but I think I've
already made this extraction (of a common test util) for 3.0, with this
name.

The input argument to the test function is now the 'parser_test_xmls'
directory instead of the specific sub directory. This will require that
some paths are duplicated in the test code, but it makes it easier to
debug tests from e.g. Visual Studio, since you can always give the same
path as argument then, and don't have to modify for each test.
We stored all displayUnitDefs in a separate vector, and used bsearch on it. The
problem is that unitDisplays are not globally unique with respect to name,
which means that we might return the wrong one, since they were stored in
jm_named_ptr.

The Unit/DisplayUnit API is being tested on a very high level (print if
possible) in fmi2_import_xml_test, but not asserted with expected
compared to actual. To verify my changes I therefore decided to add some
more thorough unit tests.

Spec. says "if displayUnit is defined, but not unit, then this is invalid", but it
says nothing if a variable inherits a type with a unit. Is it then valid for the
variable to have a displayUnit (assuming it matches inherited unit)?
Currently I don't have any tests for this.
Example:
Unit: "K"
    DisplayUnit: "degC"
    DisplayUnit: "degF"
Type: "type"
    unit: "K"
    displayUnit: "degC"
Variable: "var"
    declaredType: "type"
    displayUnit: "degF"
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

Successfully merging this pull request may close these issues.

1 participant