xo-unit: + basis_unit definitions + spellings + a few more
This commit is contained in:
parent
10bd972d34
commit
deda80242a
4 changed files with 141 additions and 50 deletions
|
|
@ -38,11 +38,70 @@ namespace xo {
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace bu {
|
namespace bu {
|
||||||
constexpr basis_unit nanogram = basis_unit(dim::mass, scalefactor_ratio_type(1, 1000000000));
|
// ----- mass -----
|
||||||
constexpr basis_unit microgram = basis_unit(dim::mass, scalefactor_ratio_type(1, 1000000));
|
|
||||||
constexpr basis_unit milligram = basis_unit(dim::mass, scalefactor_ratio_type(1, 1000));
|
constexpr basis_unit picogram = basis_unit(dim::mass, scalefactor_ratio_type( 1, 1000000000000));
|
||||||
constexpr basis_unit gram = basis_unit(dim::mass, scalefactor_ratio_type(1, 1));
|
constexpr basis_unit nanogram = basis_unit(dim::mass, scalefactor_ratio_type( 1, 1000000000));
|
||||||
constexpr basis_unit kilogram = basis_unit(dim::mass, scalefactor_ratio_type(1000, 1));
|
constexpr basis_unit microgram = basis_unit(dim::mass, scalefactor_ratio_type( 1, 1000000));
|
||||||
|
constexpr basis_unit milligram = basis_unit(dim::mass, scalefactor_ratio_type( 1, 1000));
|
||||||
|
constexpr basis_unit gram = basis_unit(dim::mass, scalefactor_ratio_type( 1, 1));
|
||||||
|
constexpr basis_unit kilogram = basis_unit(dim::mass, scalefactor_ratio_type( 1000, 1));
|
||||||
|
constexpr basis_unit tonne = basis_unit(dim::mass, scalefactor_ratio_type( 1000000, 1));
|
||||||
|
constexpr basis_unit kilotonne = basis_unit(dim::mass, scalefactor_ratio_type( 1000000000, 1));
|
||||||
|
constexpr basis_unit megatonne = basis_unit(dim::mass, scalefactor_ratio_type(1000000000000, 1));
|
||||||
|
|
||||||
|
// ----- distance -----
|
||||||
|
|
||||||
|
/* International spelling */
|
||||||
|
constexpr basis_unit picometre = basis_unit(dim::distance, scalefactor_ratio_type( 1, 1000000000000));
|
||||||
|
constexpr basis_unit nanometre = basis_unit(dim::distance, scalefactor_ratio_type( 1, 1000000000));
|
||||||
|
constexpr basis_unit micrometre = basis_unit(dim::distance, scalefactor_ratio_type( 1, 1000000));
|
||||||
|
constexpr basis_unit millimetre = basis_unit(dim::distance, scalefactor_ratio_type( 1, 1000));
|
||||||
|
constexpr basis_unit metre = basis_unit(dim::distance, scalefactor_ratio_type( 1, 1));
|
||||||
|
constexpr basis_unit kilometre = basis_unit(dim::distance, scalefactor_ratio_type( 1000, 1));
|
||||||
|
constexpr basis_unit megametre = basis_unit(dim::distance, scalefactor_ratio_type( 1000000, 1));
|
||||||
|
constexpr basis_unit gigametre = basis_unit(dim::distance, scalefactor_ratio_type( 1000000000, 1));
|
||||||
|
|
||||||
|
constexpr basis_unit lightsecond = basis_unit(dim::distance, scalefactor_ratio_type( 299792458, 1));
|
||||||
|
constexpr basis_unit astronomicalunit = basis_unit(dim::distance, scalefactor_ratio_type( 149597870700, 1));
|
||||||
|
|
||||||
|
/* US spelling */
|
||||||
|
constexpr basis_unit picometer = picometre;
|
||||||
|
constexpr basis_unit nanometer = nanometre;
|
||||||
|
constexpr basis_unit micrometer = micrometre;
|
||||||
|
constexpr basis_unit millimeter = millimetre;
|
||||||
|
constexpr basis_unit meter = metre;
|
||||||
|
constexpr basis_unit kilometer = kilometre;
|
||||||
|
|
||||||
|
// ----- time -----
|
||||||
|
|
||||||
|
constexpr basis_unit picosecond = basis_unit(dim::time, scalefactor_ratio_type( 1, 1000000000000));
|
||||||
|
constexpr basis_unit nanosecond = basis_unit(dim::time, scalefactor_ratio_type( 1, 1000000000));
|
||||||
|
constexpr basis_unit microsecond = basis_unit(dim::time, scalefactor_ratio_type( 1, 1000000));
|
||||||
|
constexpr basis_unit millisecond = basis_unit(dim::time, scalefactor_ratio_type( 1, 1000));
|
||||||
|
constexpr basis_unit second = basis_unit(dim::time, scalefactor_ratio_type( 1, 1));
|
||||||
|
constexpr basis_unit minute = basis_unit(dim::time, scalefactor_ratio_type( 60, 1));
|
||||||
|
constexpr basis_unit hour = basis_unit(dim::time, scalefactor_ratio_type( 3600, 1));
|
||||||
|
constexpr basis_unit day = basis_unit(dim::time, scalefactor_ratio_type( 24*3600, 1));
|
||||||
|
constexpr basis_unit week = basis_unit(dim::time, scalefactor_ratio_type( 7*24*3600, 1));
|
||||||
|
constexpr basis_unit month = basis_unit(dim::time, scalefactor_ratio_type( 30*24*3600, 1));
|
||||||
|
constexpr basis_unit year = basis_unit(dim::time, scalefactor_ratio_type((365*24+6)*3600, 1));
|
||||||
|
|
||||||
|
/* alt conventions used in finance */
|
||||||
|
constexpr basis_unit year365 = basis_unit(dim::time, scalefactor_ratio_type( 365*24*3600, 1));
|
||||||
|
constexpr basis_unit year360 = basis_unit(dim::time, scalefactor_ratio_type( 360*24*3600, 1));
|
||||||
|
/* 250 = approx number of trading days in a calendar year */
|
||||||
|
constexpr basis_unit year250 = basis_unit(dim::time, scalefactor_ratio_type( 250*24*3600, 1));
|
||||||
|
|
||||||
|
// ----- currency -----
|
||||||
|
|
||||||
|
/* pseudounit -- placeholder for any actual currency amount */
|
||||||
|
constexpr basis_unit currency = basis_unit(dim::currency, scalefactor_ratio_type( 1, 1));
|
||||||
|
|
||||||
|
// ----- price -----
|
||||||
|
|
||||||
|
/* psuedounit -- context-dependent interpretation */
|
||||||
|
constexpr basis_unit price = basis_unit(dim::price, scalefactor_ratio_type( 1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace units {
|
namespace units {
|
||||||
|
|
@ -84,6 +143,7 @@ namespace xo {
|
||||||
native_unit2_v[static_cast<std::uint32_t>(basis_dim)].abbrev_str())));
|
native_unit2_v[static_cast<std::uint32_t>(basis_dim)].abbrev_str())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NOT_USING
|
||||||
template <dim BasisDim,
|
template <dim BasisDim,
|
||||||
std::int64_t InnerScaleNum,
|
std::int64_t InnerScaleNum,
|
||||||
std::int64_t InnerScaleDen>
|
std::int64_t InnerScaleDen>
|
||||||
|
|
@ -109,12 +169,12 @@ namespace xo {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct scaled_native_unit2_abbrev<dim::mass, 1, 1000000> {
|
struct scaled_native_unit2_abbrev<dim::mass, bu::microgram.scalefactor().num(), bu::microgram.scalefactor().den()> {
|
||||||
static constexpr const basis_unit2_abbrev_type value = basis_unit2_abbrev_type::from_chars("ug");
|
static constexpr const basis_unit2_abbrev_type value = basis_unit2_abbrev_type::from_chars("ug");
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct scaled_native_unit2_abbrev<dim::mass, 1, 1000> {
|
struct scaled_native_unit2_abbrev<dim::mass, bu::milligram.scalefactor().num(), bu::milligram.scalefactor().den()> {
|
||||||
static constexpr const basis_unit2_abbrev_type value = basis_unit2_abbrev_type::from_chars("mg");
|
static constexpr const basis_unit2_abbrev_type value = basis_unit2_abbrev_type::from_chars("mg");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -206,8 +266,10 @@ namespace xo {
|
||||||
|
|
||||||
template <dim BasisDim, std::int64_t InnerScaleNum = 1, std::int64_t InnerScaleDen = 1>
|
template <dim BasisDim, std::int64_t InnerScaleNum = 1, std::int64_t InnerScaleDen = 1>
|
||||||
constexpr auto scaled_native_unit2_abbrev_v = scaled_native_unit2_abbrev<BasisDim, InnerScaleNum, InnerScaleDen>::value;
|
constexpr auto scaled_native_unit2_abbrev_v = scaled_native_unit2_abbrev<BasisDim, InnerScaleNum, InnerScaleDen>::value;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} /*namespace qty*/
|
} /*namespace qty*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ namespace xo {
|
||||||
return basis_unit2_abbrev_type::from_chars("ug");
|
return basis_unit2_abbrev_type::from_chars("ug");
|
||||||
case 1000000000:
|
case 1000000000:
|
||||||
return basis_unit2_abbrev_type::from_chars("ng");
|
return basis_unit2_abbrev_type::from_chars("ng");
|
||||||
|
case 1000000000000:
|
||||||
|
return basis_unit2_abbrev_type::from_chars("pg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,6 +58,8 @@ namespace xo {
|
||||||
return basis_unit2_abbrev_type::from_chars("t");
|
return basis_unit2_abbrev_type::from_chars("t");
|
||||||
case 1000000000:
|
case 1000000000:
|
||||||
return basis_unit2_abbrev_type::from_chars("kt");
|
return basis_unit2_abbrev_type::from_chars("kt");
|
||||||
|
case 1000000000000:
|
||||||
|
return basis_unit2_abbrev_type::from_chars("Mt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,6 +82,8 @@ namespace xo {
|
||||||
return basis_unit2_abbrev_type::from_chars("um");
|
return basis_unit2_abbrev_type::from_chars("um");
|
||||||
case 1000000000:
|
case 1000000000:
|
||||||
return basis_unit2_abbrev_type::from_chars("nm");
|
return basis_unit2_abbrev_type::from_chars("nm");
|
||||||
|
case 1000000000000:
|
||||||
|
return basis_unit2_abbrev_type::from_chars("pm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,8 +93,12 @@ namespace xo {
|
||||||
return basis_unit2_abbrev_type::from_chars("km");
|
return basis_unit2_abbrev_type::from_chars("km");
|
||||||
case 1000000:
|
case 1000000:
|
||||||
return basis_unit2_abbrev_type::from_chars("Mm");
|
return basis_unit2_abbrev_type::from_chars("Mm");
|
||||||
|
case 299792458:
|
||||||
|
return basis_unit2_abbrev_type::from_chars("lsec");
|
||||||
case 1000000000:
|
case 1000000000:
|
||||||
return basis_unit2_abbrev_type::from_chars("Gm");
|
return basis_unit2_abbrev_type::from_chars("Gm");
|
||||||
|
case 149597870700:
|
||||||
|
return basis_unit2_abbrev_type::from_chars("AU");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,6 +121,8 @@ namespace xo {
|
||||||
return basis_unit2_abbrev_type::from_chars("us");
|
return basis_unit2_abbrev_type::from_chars("us");
|
||||||
case 1000000000:
|
case 1000000000:
|
||||||
return basis_unit2_abbrev_type::from_chars("ns");
|
return basis_unit2_abbrev_type::from_chars("ns");
|
||||||
|
case 1000000000000:
|
||||||
|
return basis_unit2_abbrev_type::from_chars("ps");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,6 +144,8 @@ namespace xo {
|
||||||
return basis_unit2_abbrev_type::from_chars("yr360");
|
return basis_unit2_abbrev_type::from_chars("yr360");
|
||||||
case 365*24*3600:
|
case 365*24*3600:
|
||||||
return basis_unit2_abbrev_type::from_chars("yr365");
|
return basis_unit2_abbrev_type::from_chars("yr365");
|
||||||
|
case 365*24*3600+6*3600:
|
||||||
|
return basis_unit2_abbrev_type::from_chars("yr");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +175,7 @@ namespace xo {
|
||||||
if (scalefactor.num() == 1) {
|
if (scalefactor.num() == 1) {
|
||||||
switch(scalefactor.den()) {
|
switch(scalefactor.den()) {
|
||||||
case 1:
|
case 1:
|
||||||
return basis_unit2_abbrev_type::from_chars("ccy");
|
return basis_unit2_abbrev_type::from_chars("px");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ namespace xo {
|
||||||
this->bu_establish_abbrev
|
this->bu_establish_abbrev
|
||||||
(basis_unit(BasisDim,
|
(basis_unit(BasisDim,
|
||||||
scalefactor_ratio_type(InnerScaleNum, InnerScaleDen)),
|
scalefactor_ratio_type(InnerScaleNum, InnerScaleDen)),
|
||||||
units::scaled_native_unit2_abbrev_v<BasisDim, InnerScaleNum, InnerScaleDen>);
|
abbrev::basis_unit2_abbrev(BasisDim, scalefactor_ratio_type(InnerScaleNum, InnerScaleDen)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief establish abbreviation @p abbrev for basis unit @p bu
|
/** @brief establish abbreviation @p abbrev for basis unit @p bu
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ namespace xo {
|
||||||
namespace ut {
|
namespace ut {
|
||||||
/* compile-time tests */
|
/* compile-time tests */
|
||||||
|
|
||||||
|
namespace bu = xo::qty::bu;
|
||||||
namespace su2 = xo::qty::su2;
|
namespace su2 = xo::qty::su2;
|
||||||
|
|
||||||
using xo::qty::Quantity;
|
using xo::qty::Quantity;
|
||||||
|
|
@ -27,7 +28,7 @@ namespace xo {
|
||||||
using xo::qty::native_unit2_v;
|
using xo::qty::native_unit2_v;
|
||||||
using xo::qty::scalefactor_ratio_type;
|
using xo::qty::scalefactor_ratio_type;
|
||||||
using xo::qty::units::scaled_native_unit2_abbrev;
|
using xo::qty::units::scaled_native_unit2_abbrev;
|
||||||
using xo::qty::units::scaled_native_unit2_abbrev_v;
|
//using xo::qty::units::scaled_native_unit2_abbrev_v;
|
||||||
using xo::qty::basis_unit;
|
using xo::qty::basis_unit;
|
||||||
using xo::qty::abbrev::basis_unit2_abbrev;;
|
using xo::qty::abbrev::basis_unit2_abbrev;;
|
||||||
using xo::qty::bpu_abbrev_type;
|
using xo::qty::bpu_abbrev_type;
|
||||||
|
|
@ -84,67 +85,80 @@ namespace xo {
|
||||||
|
|
||||||
log && log("---------------------");
|
log && log("---------------------");
|
||||||
|
|
||||||
static_assert(basis_unit(dim::mass, scalefactor_ratio_type(1, 1000000000)).abbrev()
|
/* note: using CHECK to make test show up in coverage */
|
||||||
|
|
||||||
|
# define REQUIRE_x2(x) static_assert(x); REQUIRE(x)
|
||||||
|
|
||||||
|
REQUIRE_x2(bu::picogram.abbrev() == basis_unit2_abbrev_type::from_chars("pg"));
|
||||||
|
REQUIRE_x2(bu::nanogram.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("ng"));
|
== basis_unit2_abbrev_type::from_chars("ng"));
|
||||||
static_assert(basis_unit(dim::mass, scalefactor_ratio_type(1, 1000000)).abbrev()
|
REQUIRE_x2(bu::microgram.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("ug"));
|
== basis_unit2_abbrev_type::from_chars("ug"));
|
||||||
static_assert(basis_unit(dim::mass, scalefactor_ratio_type(1, 1000)).abbrev()
|
REQUIRE_x2(bu::milligram.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("mg"));
|
== basis_unit2_abbrev_type::from_chars("mg"));
|
||||||
static_assert(basis_unit(dim::mass, scalefactor_ratio_type(1, 1)).abbrev()
|
REQUIRE_x2(bu::gram.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("g"));
|
== basis_unit2_abbrev_type::from_chars("g"));
|
||||||
static_assert(basis_unit(dim::mass, scalefactor_ratio_type(1000, 1)).abbrev()
|
REQUIRE_x2(bu::kilogram.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("kg"));
|
== basis_unit2_abbrev_type::from_chars("kg"));
|
||||||
static_assert(basis_unit(dim::mass, scalefactor_ratio_type(1000000, 1)).abbrev()
|
REQUIRE_x2(bu::tonne.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("t"));
|
== basis_unit2_abbrev_type::from_chars("t"));
|
||||||
static_assert(basis_unit(dim::mass, scalefactor_ratio_type(1000000000, 1)).abbrev()
|
REQUIRE_x2(bu::kilotonne.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("kt"));
|
== basis_unit2_abbrev_type::from_chars("kt"));
|
||||||
|
REQUIRE_x2(bu::megatonne.abbrev()
|
||||||
|
== basis_unit2_abbrev_type::from_chars("Mt"));
|
||||||
|
|
||||||
log && log(xtag("distance", basis_unit2_abbrev(dim::distance, scalefactor_ratio_type(1, 1))));
|
log && log(xtag("distance", basis_unit2_abbrev(dim::distance, scalefactor_ratio_type(1, 1))));
|
||||||
|
|
||||||
static_assert(basis_unit(dim::distance, scalefactor_ratio_type(1, 1000000000)).abbrev()
|
REQUIRE_x2(bu::picometre.abbrev()
|
||||||
|
== basis_unit2_abbrev_type::from_chars("pm"));
|
||||||
|
REQUIRE_x2(bu::nanometre.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("nm"));
|
== basis_unit2_abbrev_type::from_chars("nm"));
|
||||||
static_assert(basis_unit(dim::distance, scalefactor_ratio_type(1, 1000000)).abbrev()
|
REQUIRE_x2(bu::micrometre.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("um"));
|
== basis_unit2_abbrev_type::from_chars("um"));
|
||||||
static_assert(basis_unit(dim::distance, scalefactor_ratio_type(1, 1000)).abbrev()
|
REQUIRE_x2(bu::millimetre.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("mm"));
|
== basis_unit2_abbrev_type::from_chars("mm"));
|
||||||
static_assert(basis_unit(dim::distance, scalefactor_ratio_type(1, 1)).abbrev()
|
REQUIRE_x2(bu::metre.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("m"));
|
== basis_unit2_abbrev_type::from_chars("m"));
|
||||||
static_assert(basis_unit(dim::distance, scalefactor_ratio_type(1000, 1)).abbrev()
|
REQUIRE_x2(bu::kilometre.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("km"));
|
== basis_unit2_abbrev_type::from_chars("km"));
|
||||||
static_assert(basis_unit(dim::distance, scalefactor_ratio_type(1000000, 1)).abbrev()
|
REQUIRE_x2(bu::megametre.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("Mm"));
|
== basis_unit2_abbrev_type::from_chars("Mm"));
|
||||||
static_assert(basis_unit(dim::distance, scalefactor_ratio_type(1000000000, 1)).abbrev()
|
REQUIRE_x2(bu::gigametre.abbrev()
|
||||||
== basis_unit2_abbrev_type::from_chars("Gm"));
|
== basis_unit2_abbrev_type::from_chars("Gm"));
|
||||||
|
|
||||||
|
REQUIRE_x2(bu::lightsecond.abbrev() == basis_unit2_abbrev_type::from_chars("lsec"));
|
||||||
|
REQUIRE_x2(bu::astronomicalunit.abbrev() == basis_unit2_abbrev_type::from_chars("AU"));
|
||||||
|
|
||||||
log && log(xtag("time", basis_unit2_abbrev(dim::time, scalefactor_ratio_type(1, 1))));
|
log && log(xtag("time", basis_unit2_abbrev(dim::time, scalefactor_ratio_type(1, 1))));
|
||||||
|
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(1, 1000000000)).abbrev()
|
REQUIRE_x2(bu::second.abbrev() == basis_unit2_abbrev_type::from_chars("s"));
|
||||||
== basis_unit2_abbrev_type::from_chars("ns"));
|
REQUIRE_x2(bu::picosecond.abbrev() == basis_unit2_abbrev_type::from_chars("ps"));
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(1, 1000000)).abbrev()
|
REQUIRE_x2(bu::nanosecond.abbrev() == basis_unit2_abbrev_type::from_chars("ns"));
|
||||||
== basis_unit2_abbrev_type::from_chars("us"));
|
REQUIRE_x2(bu::microsecond.abbrev() == basis_unit2_abbrev_type::from_chars("us"));
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(1, 1000000)).abbrev()
|
REQUIRE_x2(bu::millisecond.abbrev() == basis_unit2_abbrev_type::from_chars("ms"));
|
||||||
== basis_unit2_abbrev_type::from_chars("us"));
|
REQUIRE_x2(bu::second.abbrev() == basis_unit2_abbrev_type::from_chars("s"));
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(1, 1000)).abbrev()
|
REQUIRE_x2(bu::minute.abbrev() == basis_unit2_abbrev_type::from_chars("min"));
|
||||||
== basis_unit2_abbrev_type::from_chars("ms"));
|
REQUIRE_x2(bu::hour.abbrev() == basis_unit2_abbrev_type::from_chars("hr"));
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(1, 1)).abbrev()
|
REQUIRE_x2(bu::day.abbrev() == basis_unit2_abbrev_type::from_chars("dy"));
|
||||||
== basis_unit2_abbrev_type::from_chars("s"));
|
REQUIRE_x2(bu::week.abbrev() == basis_unit2_abbrev_type::from_chars("wk"));
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(60, 1)).abbrev()
|
REQUIRE_x2(bu::month.abbrev() == basis_unit2_abbrev_type::from_chars("mo"));
|
||||||
== basis_unit2_abbrev_type::from_chars("min"));
|
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(3600, 1)).abbrev()
|
|
||||||
== basis_unit2_abbrev_type::from_chars("hr"));
|
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(24*3600, 1)).abbrev()
|
|
||||||
== basis_unit2_abbrev_type::from_chars("dy"));
|
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(7*24*3600, 1)).abbrev()
|
|
||||||
== basis_unit2_abbrev_type::from_chars("wk"));
|
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(30*24*3600, 1)).abbrev()
|
|
||||||
== basis_unit2_abbrev_type::from_chars("mo"));
|
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(250*24*3600, 1)).abbrev()
|
|
||||||
== basis_unit2_abbrev_type::from_chars("yr250"));
|
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(360*24*3600, 1)).abbrev()
|
|
||||||
== basis_unit2_abbrev_type::from_chars("yr360"));
|
|
||||||
static_assert(basis_unit(dim::time, scalefactor_ratio_type(365*24*3600, 1)).abbrev()
|
|
||||||
== basis_unit2_abbrev_type::from_chars("yr365"));
|
|
||||||
|
|
||||||
|
REQUIRE_x2(bu::year.abbrev() == basis_unit2_abbrev_type::from_chars("yr"));
|
||||||
|
REQUIRE_x2(bu::year250.abbrev() == basis_unit2_abbrev_type::from_chars("yr250"));
|
||||||
|
REQUIRE_x2(bu::year360.abbrev() == basis_unit2_abbrev_type::from_chars("yr360"));
|
||||||
|
REQUIRE_x2(bu::year365.abbrev() == basis_unit2_abbrev_type::from_chars("yr365"));
|
||||||
|
|
||||||
|
log && log(xtag("currency", basis_unit2_abbrev(dim::currency, scalefactor_ratio_type(1, 1))));
|
||||||
|
|
||||||
|
REQUIRE_x2(bu::currency.abbrev() == flatstring("ccy"));
|
||||||
|
|
||||||
|
log && log(xtag("price", basis_unit2_abbrev(dim::price, scalefactor_ratio_type(1, 1))));
|
||||||
|
|
||||||
|
REQUIRE_x2(bu::price.abbrev() == flatstring("px"));
|
||||||
|
|
||||||
|
# undef REQUIRE_x2
|
||||||
|
|
||||||
|
#ifdef OBSOLETE
|
||||||
log && log("---------------------");
|
log && log("---------------------");
|
||||||
|
|
||||||
log && log(xtag("mass*10^-9", scaled_native_unit2_abbrev_v<dim::mass, 1, 1000000000>));
|
log && log(xtag("mass*10^-9", scaled_native_unit2_abbrev_v<dim::mass, 1, 1000000000>));
|
||||||
|
|
@ -181,6 +195,7 @@ namespace xo {
|
||||||
/* proof that scaled_native_unit2_abbrev::value is constexpr */
|
/* proof that scaled_native_unit2_abbrev::value is constexpr */
|
||||||
static_assert(scaled_native_unit2_abbrev_v<dim::mass>
|
static_assert(scaled_native_unit2_abbrev_v<dim::mass>
|
||||||
== basis_unit2_abbrev_type::from_flatstring(xo::flatstring("g")));
|
== basis_unit2_abbrev_type::from_flatstring(xo::flatstring("g")));
|
||||||
|
#endif
|
||||||
|
|
||||||
} /*TEST_CASE(basis_unit)*/
|
} /*TEST_CASE(basis_unit)*/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue