Skip to content

Conformance to Ucum Functional Tests

zodikadem edited this page Dec 4, 2019 · 4 revisions

Conformance

You may declare conformance to UCUM functional tests if your implementation accepts the functional xml tests file available at https://unitsofmeasure.org/trac/attachment/wiki/FunctionalTests/UcumFunctionalTests.2.xml as an input, and passes all its test cases. The xml file is maintained by Grahame Grieve at https://unitsofmeasure.org/trac/wiki/FunctionalTests#no1

You may qualify the conformance to particular kinds of cases if your functionality does not cover all the tests. Note that conformance to these tests does not equate to conformance to UCUM itself - though one could reasonably claim to be compliant with UCUM if one is conformant to these tests.

The following section describes the content of the xml file as to help you write tests against it.

Functional Test xml file description

The xml file contains the following section


History

This section in the document merely serves as to document changes to the xml. It is the file history.


Validation

This section in the document list out tests cases and serves to validate units that should be available or not in the framework. Here is an example:

Example 1: <case id="1-101" unit="m" valid="true"/>

Example 2: <case id="1-102" unit="m/" valid="false" reason="/ is not followed by a term"/>

In the above example, the id is used as a reference to a test case. The unit attribute represents the unit that should be valid or not; based on the valid attribute value. The value true of the attribute valid indicate that the unit should be available in your implementation and the value false indicate the opposite. The attribute reason which is only exists when the valid attribute is false gives the reason why the unit should not be available.


DisplayNameGeneration

This section test whether your implementation is able to print out a correct human readable form of the units. Here is an example:

Example: <case id="2-104" unit="m[H2O]" display="(meter of water column)"/>

In the above test case, the display attribute shows the human readable form of the unit that your implementation should comply with.


Conversion

This section lists out test cases for units conversion. Here is example:

Example: <case dstUnit="s/m" id="3-116" outcome="6300" srcUnit="s/mm" value="6.3"/>

In the above example conversion from source unit must be equal to the value of the outcome attribute.


Multiplication

Example:

<case id="4-101" u1="g" u2="m" uRes="g.m" v1="1.5" v2="2" vRes="3.0"/>

<case id="4-102" u1="m" u2="g" uRes="g.m" v1="2" v2="1.5" vRes="3.0"/>

Given v1/u1, and v2/u2, multiply them together should get something that is canonically equal to vRes/uRes