xo-unit: + abbrevs + tests for imperial units {in,ft,yd,mi}
This commit is contained in:
parent
5f20b53485
commit
f4c1ef5ee6
2 changed files with 17 additions and 0 deletions
|
|
@ -114,9 +114,21 @@ namespace xo {
|
|||
return bu_abbrev_type::from_chars("AU");
|
||||
}
|
||||
}
|
||||
|
||||
if (scalefactor.den() == 10000) {
|
||||
switch(scalefactor.num()) {
|
||||
case 3048:
|
||||
return bu_abbrev_type::from_chars("ft");
|
||||
case 3*3048:
|
||||
return bu_abbrev_type::from_chars("yd");
|
||||
case 5280*3048:
|
||||
return bu_abbrev_type::from_chars("mi");
|
||||
}
|
||||
}
|
||||
|
||||
if (scalefactor.num() == 3048 && scalefactor.den() == 120000)
|
||||
return bu_abbrev_type::from_chars("in");
|
||||
|
||||
return fallback_unit_abbrev(scalefactor, dimension::distance);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,6 +111,11 @@ namespace xo {
|
|||
REQUIRE_x2(bu::lightsecond.abbrev() == flatstring("lsec"));
|
||||
REQUIRE_x2(bu::astronomicalunit.abbrev() == flatstring("AU"));
|
||||
|
||||
REQUIRE_x2(bu::inch.abbrev() == flatstring("in"));
|
||||
REQUIRE_x2(bu::foot.abbrev() == flatstring("ft"));
|
||||
REQUIRE_x2(bu::yard.abbrev() == flatstring("yd"));
|
||||
REQUIRE_x2(bu::mile.abbrev() == flatstring("mi"));
|
||||
|
||||
log && log(xtag("time", basis_unit2_abbrev(dim::time, scalefactor_ratio_type(1, 1))));
|
||||
|
||||
REQUIRE_x2(bu::picosecond.abbrev() == bu_abbrev_type::from_chars("ps"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue