Skip to content

Commit

Permalink
Merge pull request #21 from LoliGothick/develop
Browse files Browse the repository at this point in the history
fix: scaled units quantifiers derive system of quantity of its base.
  • Loading branch information
loliGothicK authored Feb 27, 2020
2 parents 05f6cf8 + b3b1d5d commit 46b9ae3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion include/mitama/dimensional/units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ template <class, class> struct scaled_unit;
template <template <class> class Synonym, class Base, class Scale>
struct scaled_unit<Synonym<dimensional_t<Base>>, Scale> {
using type = make_dimensional_t<
units_t<Base::index, typename Base::dimension_type, typename Base::exponent, std::ratio_multiply<typename Base::scale, Scale>>>;
units_t<
Base::index,
typename Base::dimension_type,
typename Base::exponent,
std::ratio_multiply<typename Base::scale, Scale>,
typename Base::system_type
>
>;
};

template <class Base, class R>
Expand Down
6 changes: 3 additions & 3 deletions tests/basic-tests/basic-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ TEMPLATE_TEST_CASE("constructor from values",
"[quantity][constructor]",
si::meter_t, si::ampere_t, si::candela_t, si::kelvin_t, si::kilogram_t, si::mol_t, si::second_t)
{
si::quantity_t<TestType, int> a(1);
REQUIRE( a == (1|TestType{}) );
si::quantity_t<TestType, int> a = 1 | si::kilo * TestType{};
REQUIRE( a == (1'000|TestType{}) );

si::quantity_t<scaled_unit_t<TestType, std::milli>, double> b = a;
REQUIRE( b.value() == 1000 );
REQUIRE( b.value() == 1'000'000 );
}

TEMPLATE_TEST_CASE("validates",
Expand Down

0 comments on commit 46b9ae3

Please sign in to comment.