Skip to content

Commit

Permalink
Merge branch 'main' into chiphogg/doc#90
Browse files Browse the repository at this point in the history
  • Loading branch information
chiphogg committed Dec 2, 2024
2 parents d0d5d85 + 72c2d06 commit 0bc658f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion au/code/au/unit_symbol.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace au {
template <typename Unit>
struct SymbolFor : detail::MakesQuantityFromNumber<SymbolFor, Unit>,
detail::ScalesQuantity<SymbolFor, Unit>,
detail::ComposesWith<SymbolFor, Unit, SymbolFor, SymbolFor> {};
detail::ComposesWith<SymbolFor, Unit, SymbolFor, SymbolFor>,
detail::CanScaleByMagnitude<SymbolFor, Unit> {};

//
// Create a unit symbol using the more fluent APIs that unit slots make possible. For example:
Expand Down
8 changes: 8 additions & 0 deletions au/code/au/unit_symbol_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ TEST(SymbolFor, ScalesUnitsOfExistingQuantity) {

TEST(SymbolFor, CompatibleWithUnitSlot) { EXPECT_THAT(meters(35u).in(m), SameTypeAndValue(35u)); }

TEST(SymbolFor, CanScaleByMagnitude) {
// Yes, the identifier name is a little awkward for these symbols for anonymous scaled units.
// But it's still important to have this functionality.
constexpr auto u100_m = mag<100>() * m;

EXPECT_THAT(3.5f / u100_m, SameTypeAndValue(inverse(meters * mag<100>())(3.5f)));
}

} // namespace au

0 comments on commit 0bc658f

Please sign in to comment.