From 0ad78fe7532892cf4c596defcfcfefa75e685570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Sch=C3=B6nrock?= Date: Sat, 28 Dec 2019 10:37:18 +0000 Subject: [PATCH] small changes based on code review --- src/include/units/bits/unit_text.h | 4 +-- src/include/units/physical/si/prefixes.h | 41 ++++++++++++------------ src/include/units/quantity.h | 2 +- test/unit_test/runtime/fmt_test.cpp | 16 ++++----- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/include/units/bits/unit_text.h b/src/include/units/bits/unit_text.h index 850e7f57..f9629c89 100644 --- a/src/include/units/bits/unit_text.h +++ b/src/include/units/bits/unit_text.h @@ -35,12 +35,12 @@ constexpr auto ratio_text() return txt + basic_fixed_string("]"); } else if constexpr (Ratio::den == 1) { - return txt + basic_fixed_string(" x 10") + superscript() + + return txt + basic_fixed_string(" \u00D7 10") + superscript() + basic_fixed_string("]"); } else { return txt + basic_fixed_string("/") + regular() + - basic_fixed_string(" x 10") + superscript() + + basic_fixed_string(" \u00D7 10") + superscript() + basic_fixed_string("]"); } } diff --git a/src/include/units/physical/si/prefixes.h b/src/include/units/physical/si/prefixes.h index 541ce36d..30d3e8ad 100644 --- a/src/include/units/physical/si/prefixes.h +++ b/src/include/units/physical/si/prefixes.h @@ -23,31 +23,32 @@ #pragma once #include -#include namespace units::si { struct prefix : prefix_type {}; -// TODO Remove dependency on std::ratio - -// clang-format off -struct atto : units::prefix> {}; // std::atto::den>> {}; -struct femto : units::prefix> {}; // std::femto::den>> {}; -struct pico : units::prefix> {}; // std::pico::den>> {}; -struct nano : units::prefix> {}; // std::nano::den>> {}; -struct micro : units::prefix> {}; // std::micro::den>> {}; -struct milli : units::prefix> {}; // std::milli::den>> {}; -struct centi : units::prefix> {}; // std::centi::den>> {}; -struct deci : units::prefix> {}; // std::deci::den>> {}; -struct deca : units::prefix> {}; // std::deca::num>> {}; -struct hecto : units::prefix> {}; // std::hecto::num>> {}; -struct kilo : units::prefix> {}; // std::kilo::num>> {}; -struct mega : units::prefix> {}; // std::mega::num>> {}; -struct giga : units::prefix> {}; // std::giga::num>> {}; -struct tera : units::prefix> {}; // std::tera::num>> {}; -struct peta : units::prefix> {}; // std::peta::num>> {}; -struct exa : units::prefix> {}; // std::exa::num>> {}; // clang-format off +struct yocto : units::prefix> {}; +struct zepto : units::prefix> {}; +struct atto : units::prefix> {}; +struct femto : units::prefix> {}; +struct pico : units::prefix> {}; +struct nano : units::prefix> {}; +struct micro : units::prefix> {}; +struct milli : units::prefix> {}; +struct centi : units::prefix> {}; +struct deci : units::prefix> {}; +struct deca : units::prefix> {}; +struct hecto : units::prefix> {}; +struct kilo : units::prefix> {}; +struct mega : units::prefix> {}; +struct giga : units::prefix> {}; +struct tera : units::prefix> {}; +struct peta : units::prefix> {}; +struct exa : units::prefix> {}; +struct zetta : units::prefix> {}; +struct yotta : units::prefix> {}; +// clang-format on } // namespace units::si diff --git a/src/include/units/quantity.h b/src/include/units/quantity.h index ebcfe6ba..6425fba6 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -1,3 +1,4 @@ + // The MIT License (MIT) // // Copyright (c) 2018 Mateusz Pusz @@ -32,7 +33,6 @@ #endif #include -#include namespace units { diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index 13ca5176..979866eb 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -296,7 +296,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("iostream") { - CHECK(stream.str() == "8 [1 x 10⁻²]m³"); + CHECK(stream.str() == "8 [1 \u00D7 10⁻²]m³"); } SECTION("fmt with default format {} on a quantity") @@ -317,7 +317,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("iostream") { - CHECK(stream.str() == "2 [6 x 10¹]Hz"); + CHECK(stream.str() == "2 [6 \u00D7 10¹]Hz"); } SECTION("fmt with default format {} on a quantity") @@ -338,7 +338,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("iostream") { - CHECK(stream.str() == "10 [1/6 x 10⁻¹]W"); + CHECK(stream.str() == "10 [1/6 \u00D7 10⁻¹]W"); } SECTION("fmt with default format {} on a quantity") @@ -359,7 +359,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("iostream") { - CHECK(stream.str() == "30 [1/6 x 10²]W"); + CHECK(stream.str() == "30 [1/6 \u00D7 10²]W"); } SECTION("fmt with default format {} on a quantity") @@ -404,7 +404,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("iostream") { - CHECK(stream.str() == "8 [1 x 10³]m⋅s"); + CHECK(stream.str() == "8 [1 \u00D7 10³]m⋅s"); } SECTION("fmt with default format {} on a quantity") @@ -425,7 +425,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("iostream") { - CHECK(stream.str() == "2 [6 x 10¹]kg/s"); + CHECK(stream.str() == "2 [6 \u00D7 10¹]kg/s"); } SECTION("fmt with default format {} on a quantity") @@ -446,7 +446,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("iostream") { - CHECK(stream.str() == "10 [1/6 x 10⁻¹]kg/s"); + CHECK(stream.str() == "10 [1/6 \u00D7 10⁻¹]kg/s"); } SECTION("fmt with default format {} on a quantity") @@ -467,7 +467,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("iostream") { - CHECK(stream.str() == "30 [6 x 10⁻²]1/m⋅s"); + CHECK(stream.str() == "30 [6 \u00D7 10⁻²]1/m⋅s"); } SECTION("fmt with default format {} on a quantity")