blob: 99427984b728e30bd332ce1f494d515822eb9298 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
Ucum Functional Tests.
This file is maintained by Grahame Grieve (
Contributions/Corrections are welcome, and are best made through
the trac system at
You may declare conformance to these UCUM functional tests if
your implementation accepts this file as an input, and passes
all the test cases below. You should always quote the most
recent date from the history entries below when claiming
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
This file is copyright © 2008 - 2009 Grahame Grieve and other
* Gunther Schadow
* Lloyd Mackenzie
This source is licensed for public use under the Eclipse Public License
<entry date="10-Feb 2009" author="gdg">First created. Ucum validation Tests, display name generation tests, conversion tests, and multiplication tests</entry>
<!-- Note: all tests use case sensitive codes -->
These tests check that ucum validation code is working correctly.
Each case has a unit, and whether the specified unit is valid or not
No particular error is specified, but a hint is provided for why the
unit is not valid
<case id="1-101" unit="m" valid="true"/>
<case id="1-102" unit="m/" valid="false" reason="/ is not followed by a term"/>
<case id="1-103" unit="" valid="true"/>
<case id="1-104" unit="/m" valid="true"/>
<case id="1-105" unit="10*3/ul" valid="true"/>
<case id="1-106" unit="10*-3/ul" valid="true"/>
<case id="1-107" unit="10*+3/ul" valid="true"/>
<case id="1-108" unit="10+3/ul" valid="false" reason="10 is not a valid unit"/>
<case id="1-109" unit="m" valid="true"/>
<case id="1-110" unit="m[H2O]" valid="true"/>
<case id="1-111" unit="10*23" valid="true"/>
<case id="1-112" unit="rad2" valid="true"/>
<case id="1-113" unit="" valid="true"/>
<case id="1-114" unit="4.[pi].10*-7.N/A2" valid="true"/>
<!-- test that the parser supports both {} inserts, and unicode characters too, while we're at it -->
<case id="1-115" unit="rad2{錠}" valid="true"/>
<case id="1-116" unit="{錠}rad2{錠}" valid="true"/>
<case id="1-117" unit="1{錠}" valid="true"/>
<case id="1-118" unit="{錠}1" valid="true"/>
<case id="1-119" unit="{錠}" valid="true"/>
<case id="1-120" unit="%" valid="true"/>
These codes are taken from the first draft of a proposed Canadian UCUM subset.
(the subset was subsequently corrected after being tested) -->
<case id="1-121" unit="[cup_us]" valid="true"/>
<case id="1-122" unit="[foz_br]" valid="true"/>
<case id="1-123" unit="[ft_i]" valid="true"/>
<case id="1-124" unit="[in_i]" valid="true"/>
<case id="1-125" unit="[yd_i]" valid="true"/>
<case id="1-126" unit="[gal_br]" valid="true"/>
<case id="1-127" unit="[lb_av]" valid="true"/>
<case id="1-128" unit="[oz_av]" valid="true"/>
<case id="1-129" unit="[pt_br]" valid="true"/>
<case id="1-130" unit="[qt_br]" valid="true"/>
<case id="1-131" unit="[sft_i]" valid="true"/>
<case id="1-132" unit="[sin_i]" valid="true"/>
<case id="1-133" unit="[syd_i]" valid="true"/>
<case id="1-134" unit="[tbs_us]" valid="true"/>
<case id="1-135" unit="[tsp_us]" valid="true"/>
<case id="1-136" unit="1/d" valid="true"/>
<case id="1-137" unit="1/min" valid="true"/>
<case id="1-138" unit="a" valid="true"/>
<case id="1-139" unit="cm" valid="true"/>
<case id="1-140" unit="cm2" valid="true"/>
<case id="1-141" unit="cm3" valid="true"/>
<case id="1-142" unit="d" valid="true"/>
<case id="1-143" unit="dg" valid="true"/>
<case id="1-144" unit="dl" valid="true"/>
<case id="1-145" unit="g" valid="true"/>
<case id="1-146" unit="g/d" valid="true"/>
<case id="1-147" unit="g/l" valid="true"/>
<case id="1-148" unit="h" valid="true"/>
<case id="1-149" unit="iU" valid="false" reason="iU needs [] around it"/>
<case id="1-150" unit="kg" valid="true"/>
<case id="1-151" unit="l" valid="true"/>
<case id="1-152" unit="m" valid="true"/>
<case id="1-153" unit="mm" valid="true"/>
<case id="1-154" unit="m2" valid="true"/>
<case id="1-155" unit="meq" valid="true"/>
<case id="1-156" unit="mg" valid="true"/>
<case id="1-157" unit="mg" valid="true"/>
<case id="1-158" unit="mg/d" valid="true"/>
<case id="1-159" unit="min" valid="true"/>
<case id="1-160" unit="ml" valid="true"/>
<case id="1-161" unit="ml/s" valid="true"/>
<case id="1-162" unit="mm[Hg]" valid="true"/>
<case id="1-163" unit="mm2" valid="true"/>
<case id="1-164" unit="mm3" valid="true"/>
<case id="1-165" unit="mmol" valid="true"/>
<case id="1-166" unit="mmol/l" valid="true"/>
<case id="1-167" unit="mo" valid="true"/>
<case id="1-168" unit="mol" valid="true"/>
<case id="1-169" unit="ms" valid="true"/>
<case id="1-170" unit="mU" valid="true"/>
<case id="1-171" unit="ng" valid="true"/>
<case id="1-172" unit="ng" valid="true"/>
<case id="1-173" unit="nl" valid="true"/>
<case id="1-174" unit="nl" valid="true"/>
<case id="1-175" unit="pg/ml" valid="true"/>
<case id="1-176" unit="s" valid="true"/>
<case id="1-177" unit="U" valid="true"/>
<case id="1-178" unit="U/l" valid="true"/>
<case id="1-179" unit="ug" valid="true"/>
<case id="1-180" unit="ug/min" valid="true"/>
<case id="1-181" unit="ul" valid="true"/>
<case id="1-182" unit="umol" valid="true"/>
<case id="1-183" unit="umol/l" valid="true"/>
<case id="1-184" unit="wk" valid="true"/>
<case id="1-185" unit="%" valid="true"/>
<case id="1-186" unit="[cup_us]" valid="true"/>
<case id="1-187" unit="[foz_br]" valid="true"/>
<case id="1-188" unit="[gal_br]" valid="true"/>
<case id="1-189" unit="[sft_i]" valid="true"/>
<case id="1-190" unit="[sin_i]" valid="true"/>
<case id="1-191" unit="[lb_av]" valid="true"/>
<case id="1-192" unit="[oz_av]" valid="true"/>
<case id="1-193" unit="[pt_br]" valid="true"/>
<case id="1-194" unit="[qt_br]" valid="true"/>
<case id="1-195" unit="[tbs_us]" valid="true"/>
<case id="1-196" unit="[tsp_us]" valid="true"/>
<case id="1-197" unit="[syd_i]" valid="true"/>
<case id="1-198" unit="cm2" valid="true"/>
<case id="1-199" unit="cm3" valid="true"/>
<case id="1-200" unit="g" valid="true"/>
<case id="1-201" unit="kg" valid="true"/>
<case id="1-202" unit="l" valid="true"/>
<case id="1-203" unit="m2" valid="true"/>
<case id="1-204" unit="meq" valid="true"/>
<case id="1-205" unit="mg" valid="true"/>
<case id="1-206" unit="ml" valid="true"/>
<case id="1-207" unit="mm2" valid="true"/>
<case id="1-208" unit="mm3" valid="true"/>
<case id="1-209" unit="mmol" valid="true"/>
<case id="1-210" unit="molv" valid="false" reason="molv is not a valid unit"/>
<case id="1-211" unit="mU" valid="true"/>
<case id="1-212" unit="ng" valid="true"/>
<case id="1-213" unit="nl" valid="true"/>
<case id="1-214" unit="U" valid="true"/>
<case id="1-215" unit="ug" valid="true"/>
<case id="1-216" unit="ul" valid="true"/>
<case id="1-217" unit="umol" valid="true"/>
<case id="1-218" unit="a" valid="true"/>
<case id="1-219" unit="d" valid="true"/>
<case id="1-220" unit="h" valid="true"/>
<case id="1-221" unit="min" valid="true"/>
<case id="1-222" unit="mo" valid="true"/>
<case id="1-223" unit="s" valid="true"/>
<case id="1-224" unit="wk" valid="true"/>
<case id="1-225" unit="[ft_i]" valid="true"/>
<case id="1-226" unit="[in_i]" valid="true"/>
<case id="1-227" unit="[lb_av]" valid="true"/>
<case id="1-228" unit="[oz_av]" valid="true"/>
<case id="1-229" unit="[yd_i]" valid="true"/>
<case id="1-230" unit="cm" valid="true"/>
<case id="1-231" unit="g" valid="true"/>
<case id="1-232" unit="kg" valid="true"/>
<case id="1-233" unit="m" valid="true"/>
<case id="1-234" unit="mm" valid="true"/>
<case id="1-235" unit="[mi_us]" valid="true"/>
<case id="1-236" unit="[yd_i]" valid="true"/>
<case id="1-237" unit="deg" valid="true"/>
<case id="1-238" unit="km" valid="true"/>
<case id="1-239" unit="m" valid="true"/>
<case id="1-240" unit="%" valid="true"/>
<case id="1-241" unit="/[HPF]" valid="true"/>
<case id="1-242" unit="/[LPF]" valid="true"/>
<case id="1-243" unit="/L" valid="true"/>
<case id="1-244" unit="/mL" valid="true"/>
<case id="1-245" unit="/mmol" valid="true"/>
<case id="1-246" unit="[APL'U]" valid="true"/>
<case id="1-247" unit="[BETH'U]" valid="false" reason="not a valid unit"/>
<case id="1-248" unit="[GPL'U]" valid="true"/>
<case id="1-249" unit="[IU]" valid="false" reason="not a valid unit (iU)"/>
<case id="1-250" unit="[IU]/d" valid="false" reason="not a valid unit (iU)"/>
<case id="1-251" unit="[IU]/L" valid="false" reason="not a valid unit (iU)"/>
<case id="1-252" unit="[IU]/mL" valid="false" reason="not a valid unit (iU)"/>
<case id="1-253" unit="[MPL'U]" valid="true"/>
<case id="1-254" unit="10*12/L" valid="true"/>
<case id="1-255" unit="10*6/L" valid="true"/>
<case id="1-256" unit="10*9/L" valid="true"/>
<case id="1-257" unit="Cel" valid="true"/>
<case id="1-258" unit="cm" valid="true"/>
<case id="1-259" unit="cm/s" valid="true"/>
<case id="1-260" unit="fL" valid="true"/>
<case id="1-261" unit="fmol/L" valid="true"/>
<case id="1-262" unit="g" valid="true"/>
<case id="1-263" unit="g/12h" valid="false" reason="not a valid unit (12h - should be 12.h)"/>
<case id="1-264" unit="g/48h" valid="false" reason="not a valid unit (48h)"/>
<case id="1-265" unit="g/4h" valid="false" reason="not a valid unit (4h)"/>
<case id="1-266" unit="g/6h" valid="false" reason="not a valid unit (6h)"/>
<case id="1-267" unit="g/72h" valid="false" reason="not a valid unit (72h)"/>
<case id="1-268" unit="g/d" valid="true"/>
<case id="1-269" unit="g/g" valid="true"/>
<case id="1-270" unit="g/L" valid="true"/>
<case id="1-271" unit="h" valid="true"/>
<case id="1-272" unit="km" valid="true"/>
<case id="1-273" unit="kU/L" valid="true"/>
<case id="1-274" unit="L/L" valid="true"/>
<case id="1-275" unit="m[IU]/L" valid="false" reason="not a valid unit (iU)"/>
<case id="1-276" unit="mg" valid="true"/>
<case id="1-277" unit="mg/12h" valid="false" reason="not a valid unit (12h)"/>
<case id="1-278" unit="mg/d" valid="true"/>
<case id="1-279" unit="mg/g" valid="true"/>
<case id="1-280" unit="mg/L" valid="true"/>
<case id="1-281" unit="mg/mg" valid="true"/>
<case id="1-282" unit="mg/mL" valid="true"/>
<case id="1-283" unit="min" valid="true"/>
<case id="1-284" unit="mL" valid="true"/>
<case id="1-285" unit="mL/10h" valid="false" reason="not a valid unit (10h)"/>
<case id="1-286" unit="mL/12h" valid="false" reason="not a valid unit (12h)"/>
<case id="1-287" unit="mL/2h" valid="false" reason="not a valid unit (2h)"/>
<case id="1-288" unit="mL/4h" valid="false" reason="not a valid unit (4h)"/>
<case id="1-289" unit="mL/5h" valid="false" reason="not a valid unit (5h)"/>
<case id="1-290" unit="mL/6h" valid="false" reason="not a valid unit (6h)"/>
<case id="1-291" unit="mL/72h" valid="false" reason="not a valid unit (72h)"/>
<case id="1-292" unit="mL/8h" valid="false" reason="not a valid unit (8h)"/>
<case id="1-293" unit="mL/d" valid="true"/>
<case id="1-294" unit="mL/min" valid="true"/>
<case id="1-295" unit="mm" valid="true"/>
<case id="1-296" unit="mm/h" valid="true"/>
<case id="1-297" unit="mm[Hg]" valid="true"/>
<case id="1-298" unit="mmol" valid="true"/>
<case id="1-299" unit="mmol/12h" valid="false" reason="not a valid unit (12h)"/>
<case id="1-300" unit="mmol/5h" valid="false" reason="not a valid unit (5h)"/>
<case id="1-301" unit="mmol/6h" valid="false" reason="not a valid unit (6h)"/>
<case id="1-302" unit="mmol/d" valid="true"/>
<case id="1-303" unit="mmol/g" valid="true"/>
<case id="1-304" unit="mmol/kg" valid="true"/>
<case id="1-305" unit="mmol/kg[H20]" valid="false" reason="not a valid unit (kg[H20])"/>
<case id="1-306" unit="mmol/L" valid="true"/>
<case id="1-307" unit="mmol/mmol" valid="true"/>
<case id="1-308" unit="mU/L" valid="true"/>
<case id="1-309" unit="ng/d" valid="true"/>
<case id="1-310" unit="ng/g" valid="true"/>
<case id="1-311" unit="ng/L" valid="true"/>
<case id="1-312" unit="ng/mL" valid="true"/>
<case id="1-313" unit="nmol/d" valid="true"/>
<case id="1-314" unit="nmol/g" valid="true"/>
<case id="1-315" unit="nmol/h/mL" valid="true"/>
<case id="1-316" unit="nmol/L" valid="true"/>
<case id="1-317" unit="nmol/mmol" valid="true"/>
<case id="1-318" unit="nmol/nmol" valid="true"/>
<case id="1-319" unit="pg" valid="true"/>
<case id="1-320" unit="pg/mL" valid="true"/>
<case id="1-321" unit="pmol/d" valid="true"/>
<case id="1-322" unit="pmol/g" valid="true"/>
<case id="1-323" unit="pmol/h/mg" valid="true"/>
<case id="1-324" unit="pmol/h/mL" valid="true"/>
<case id="1-325" unit="pmol/L" valid="true"/>
<case id="1-326" unit="pmol/mmol" valid="true"/>
<case id="1-327" unit="s" valid="true"/>
<case id="1-328" unit="U" valid="true"/>
<case id="1-329" unit="U/12h" valid="false" reason="not a valid unit (12h)"/>
<case id="1-330" unit="U/1h" valid="false" reason="not a valid unit (1h)"/>
<case id="1-331" unit="U/2h" valid="false" reason="not a valid unit (2h)"/>
<case id="1-332" unit="U/d" valid="true"/>
<case id="1-333" unit="U/g" valid="true"/>
<case id="1-334" unit="U/kg" valid="true"/>
<case id="1-335" unit="U/L" valid="true"/>
<case id="1-336" unit="U/mL" valid="true"/>
<case id="1-337" unit="u[IU]/mL" valid="false" reason="not a valid unit (iU)"/>
<case id="1-338" unit="ug" valid="true"/>
<case id="1-339" unit="ug/d" valid="true"/>
<case id="1-340" unit="ug/g" valid="true"/>
<case id="1-341" unit="ug/L" valid="true"/>
<case id="1-342" unit="ug/mL" valid="true"/>
<case id="1-343" unit="um/s" valid="true"/>
<case id="1-344" unit="umol" valid="true"/>
<case id="1-345" unit="umol/2.h" valid="true"/>
<case id="1-346" unit="umol/d" valid="true"/>
<case id="1-347" unit="umol/g" valid="true"/>
<case id="1-348" unit="umol/L" valid="true"/>
<case id="1-349" unit="umol/mmol" valid="true"/>
<case id="1-350" unit="umol/umol" valid="true"/>
<case id="1-351" unit="wk" valid="true"/>
This is a somewhat trivial concept, but here to encourage standard practice
where it matters - the ability to take a code and produce a (slightly) more
human readable long form (might correspond to the HL7 v3 / ISO data types
concept of display name)
<case id="2-101" unit="" display="1"/>
<case id="2-102" unit="m" display="(meter)"/>
<case id="2-103" unit="mm" display="(millimeter)"/>
<case id="2-104" unit="m[H2O]" display="(meter of water column)"/>
<case id="2-105" unit="10*23" display="(the number ten for arbitrary powers ^ 23)"/>
<case id="2-106" unit="rad2" display="(radian ^ 2)"/>
<case id="2-107" unit="" display="(meter ^ 3) * (kilogram ^ -1) * (second ^ -2)"/>
<case id="2-108" unit="4.[pi].10*-7.N/A2" display="4 * (the number pi) * (the number ten for arbitrary powers ^ -7) * (Newton) / (Ampère ^ 2)"/>
Conversion Tests
given value/srcUnit, what is the value in dstUnit?
Note that we don't check directly what the canonical unit is. In fact,
no particular form is actually defined for UCUM - it's up the implementor
to define their own. However these tests check that the chosen canonical
form is working correctly as they work, since it's required to perform
these conversions
<case id="3-101" value="1" srcUnit="m" dstUnit="m" outcome="1"/>
<case id="3-102" value="1" srcUnit="mm" dstUnit="m" outcome="0.001"/>
<case id="3-103" value="10" srcUnit="mm" dstUnit="cm" outcome="1.0"/>
<case id="3-104" value="1" srcUnit="[in_i]" dstUnit="m" outcome="0.0254"/>
<case id="3-105" value="1" srcUnit="[in_i]" dstUnit="cm" outcome="2.54"/>
<case id="3-106" value="1" srcUnit="[mu_0]" dstUnit="g.m.C-2" outcome="125663.7061435917295385057"/>
<case id="3-107" value="1" srcUnit="m[Hg]" dstUnit="g.s-2.m-1" outcome="133322000"/>
<case id="3-108" value="1" srcUnit="S" dstUnit="g-1.m-2.C2.s" outcome="1000"/>
Seiverts Canonicalisation (conceptual example):
C2.g-1.m-2.s (alphabetical)
<case id="3-109" value="1" srcUnit="[ly]" dstUnit="cm" outcome="946073047258080000"/>
<case id="3-110" value="1.2" srcUnit="g.m" dstUnit="m.g" outcome="1.2"/>
Given v1/u1, and v2/u2, multiply them together - should get something that is canonically equal
to vRes/uRes. Note that it doesn't have to be the same as vRes/uRes: the units
reported may differ in order or some other form, and the value may consequently
be different, but the result must convert to the stated value
<case id="4-101" v1="1.5" u1="g" v2="2" u2="m" vRes="3" uRes="g.m"/>