Skip to content

Commit

Permalink
Format "arbitrary unit" nicely (#272)
Browse files Browse the repository at this point in the history
* Fix hard-coded namespace `units` in `units_conversion_maps.hpp`

* Format "arbitrary unit" nicely

* Update test/test_unit_strings.cpp
  • Loading branch information
SimonHeybrock authored Jan 16, 2023
1 parent 5399c41 commit f8f83fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions test/test_unit_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ TEST(unitStrings, si)
EXPECT_EQ(to_string(ft * lb), "ft*lb");
}

TEST(unitStrings, laboratoryArbUnits)
{
EXPECT_EQ(to_string(precise::laboratory::arbU), "arb. unit");
}

TEST(unitStrings, numerical)
{
auto odd = unit(0.125, m);
Expand Down
4 changes: 2 additions & 2 deletions units/units_conversion_maps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-3-Clause

namespace UNITS_NAMESPACE {

UNITS_CPP14_CONSTEXPR_OBJECT std::array<std::pair<unit, const char*>, 110>
UNITS_CPP14_CONSTEXPR_OBJECT std::array<std::pair<unit, const char*>, 111>
defined_unit_names_si{
{{m, "m"},
{m * m, "m^2"},
Expand Down Expand Up @@ -116,7 +116,7 @@ UNITS_CPP14_CONSTEXPR_OBJECT std::array<std::pair<unit, const char*>, 110>
{unit_cast(precise::pressure::atm), "atm"},
{unit_cast(precise::pressure::mmHg), "mmHg"},
{unit_cast(precise::pressure::mmH2O), "mmH2O"},

{unit_cast(precise::laboratory::arbU), "arb. unit"},
{unit_cast(precise::laboratory::IU), "[IU]"},
{kWh, "kWh"},
{MWh, "MWh"},
Expand Down

0 comments on commit f8f83fa

Please sign in to comment.