diff --git a/conanfile.py b/conanfile.py index c8dafdde..28ba6bae 100644 --- a/conanfile.py +++ b/conanfile.py @@ -150,7 +150,6 @@ class UnitsConan(ConanFile): # rest self.cpp_info.components["core-io"].requires = ["core"] self.cpp_info.components["core-fmt"].requires = ["core", "fmt::fmt"] - self.cpp_info.components["data"].requires = ["core"] self.cpp_info.components["isq"].requires = ["core"] self.cpp_info.components["isq-natural"].requires = ["isq"] self.cpp_info.components["si"].requires = ["isq"] @@ -161,4 +160,5 @@ class UnitsConan(ConanFile): self.cpp_info.components["si-international"].requires = ["si"] self.cpp_info.components["si-typographic"].requires = ["si"] self.cpp_info.components["si-us"].requires = ["si"] - self.cpp_info.components["systems"].requires = ["data", "isq", "isq-natural", "si", "si-cgs", "si-fps", "si-iau", "si-imperial", "si-international", "si-typographic", "si-us"] + self.cpp_info.components["isq-iec80000"].requires = ["si"] + self.cpp_info.components["systems"].requires = ["isq", "isq-natural", "si", "si-cgs", "si-fps", "si-iau", "si-imperial", "si-international", "si-typographic", "si-us", "isq-iec80000"] diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index da13126e..0fac3f3d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,7 @@ - (!) refactor: output stream operators moved to the `units/quantity_io.h` header file - (!) refactor: Refactored the library file tree - (!) refactor: `quantity::count()` renamed to `quantity::number()` + - (!) refactor: `data` system renamed to `isq::iec80000` (quantity names renamed too) - refactor: quantity (kind) point updated to reflect latest changes to `quantity` - refactor: basic concepts, `quantity` and `quantity_cast` refactored - refactor: `abs()` definition refactored to be more explicit about the return type @@ -12,6 +13,8 @@ - feat: quantity references support added (thanks [@johelegp](https://github.com/johelegp)) - feat: interoperability with `std::chrono::duration` and other units libraries - feat: CTAD for dimensionless quantity added + - feat: `modulation_rate` support added (thanks [@go2sh](https://github.com/go2sh)) + - feat: SI prefixes for `isq::iec80000` support added (thanks [@go2sh](https://github.com/go2sh)) - perf: preconditions check do not influence the runtime performance of a Release build - perf: `quantity_cast()` generates less assembly instructions - perf: temporary string creation removed from `quantity::op<<()` diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 0186da94..79430a08 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -114,11 +114,6 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/data.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/data/bitrate.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/data/information.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/data/prefixes.rst" - "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic/angle.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/generic/dimensionless.rst" @@ -126,6 +121,13 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq.rst" + "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000.rst" + "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/binary_prefixes.rst" + "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/modulation_rate.rst" + "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/storage_capacity.rst" + "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/traffic_intensity.rst" + "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/iec80000/transfer_rate.rst" + "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/constants.rst" "${CMAKE_CURRENT_SOURCE_DIR}/reference/systems/isq/natural/dimensions.rst" diff --git a/docs/reference/systems.rst b/docs/reference/systems.rst index c8e864ac..52fb3f72 100644 --- a/docs/reference/systems.rst +++ b/docs/reference/systems.rst @@ -10,8 +10,3 @@ Systems :maxdepth: 2 systems/isq - -.. toctree:: - :maxdepth: 1 - - systems/data diff --git a/docs/reference/systems/data.rst b/docs/reference/systems/data.rst deleted file mode 100644 index b40aa769..00000000 --- a/docs/reference/systems/data.rst +++ /dev/null @@ -1,9 +0,0 @@ -Data -==== - -.. toctree:: - :maxdepth: 2 - - data/prefixes - data/information - data/bitrate diff --git a/docs/reference/systems/data/bitrate.rst b/docs/reference/systems/data/bitrate.rst deleted file mode 100644 index 03d6b81e..00000000 --- a/docs/reference/systems/data/bitrate.rst +++ /dev/null @@ -1,4 +0,0 @@ -Bitrate -======= - -.. doxygenfile:: data/bitrate.h diff --git a/docs/reference/systems/data/information.rst b/docs/reference/systems/data/information.rst deleted file mode 100644 index 37920d28..00000000 --- a/docs/reference/systems/data/information.rst +++ /dev/null @@ -1,4 +0,0 @@ -Information -=========== - -.. doxygenfile:: data/information.h diff --git a/docs/reference/systems/data/prefixes.rst b/docs/reference/systems/data/prefixes.rst deleted file mode 100644 index bfe89374..00000000 --- a/docs/reference/systems/data/prefixes.rst +++ /dev/null @@ -1,4 +0,0 @@ -Prefixes -======== - -.. doxygenfile:: data/prefixes.h diff --git a/docs/reference/systems/isq.rst b/docs/reference/systems/isq.rst index 4e7fa268..3a419e2a 100644 --- a/docs/reference/systems/isq.rst +++ b/docs/reference/systems/isq.rst @@ -6,6 +6,7 @@ International System of Quantities (ISQ) isq/dimensions_and_concepts isq/si + isq/iec80000 isq/si_cgs isq/si_international isq/si_us diff --git a/docs/reference/systems/isq/iec80000.rst b/docs/reference/systems/isq/iec80000.rst new file mode 100644 index 00000000..8e89cceb --- /dev/null +++ b/docs/reference/systems/isq/iec80000.rst @@ -0,0 +1,11 @@ +IEC 80000 +========= + +.. toctree:: + :maxdepth: 2 + + iec80000/binary_prefixes + iec80000/modulation_rate + iec80000/storage_capacity + iec80000/traffic_intensity + iec80000/transfer_rate diff --git a/docs/reference/systems/isq/iec80000/binary_prefixes.rst b/docs/reference/systems/isq/iec80000/binary_prefixes.rst new file mode 100644 index 00000000..916f3aa2 --- /dev/null +++ b/docs/reference/systems/isq/iec80000/binary_prefixes.rst @@ -0,0 +1,4 @@ +Binary Prefixes +=============== + +.. doxygenfile:: iec80000/binary_prefixes.h diff --git a/docs/reference/systems/isq/iec80000/modulation_rate.rst b/docs/reference/systems/isq/iec80000/modulation_rate.rst new file mode 100644 index 00000000..42f347a2 --- /dev/null +++ b/docs/reference/systems/isq/iec80000/modulation_rate.rst @@ -0,0 +1,4 @@ +Modulation Rate +=============== + +.. doxygenfile:: iec80000/modulation_rate.h diff --git a/docs/reference/systems/isq/iec80000/storage_capacity.rst b/docs/reference/systems/isq/iec80000/storage_capacity.rst new file mode 100644 index 00000000..7d24043b --- /dev/null +++ b/docs/reference/systems/isq/iec80000/storage_capacity.rst @@ -0,0 +1,4 @@ +Sotrage Capacity +================ + +.. doxygenfile:: iec80000/storage_capacity.h diff --git a/docs/reference/systems/isq/iec80000/traffic_intensity.rst b/docs/reference/systems/isq/iec80000/traffic_intensity.rst new file mode 100644 index 00000000..89e9a07b --- /dev/null +++ b/docs/reference/systems/isq/iec80000/traffic_intensity.rst @@ -0,0 +1,4 @@ +Traffic Intensity +================= + +.. doxygenfile:: iec80000/traffic_intensity.h diff --git a/docs/reference/systems/isq/iec80000/transfer_rate.rst b/docs/reference/systems/isq/iec80000/transfer_rate.rst new file mode 100644 index 00000000..e81dac39 --- /dev/null +++ b/docs/reference/systems/isq/iec80000/transfer_rate.rst @@ -0,0 +1,4 @@ +Transfer Rate +============= + +.. doxygenfile:: iec80000/transfer_rate.h diff --git a/src/systems/CMakeLists.txt b/src/systems/CMakeLists.txt index 47521fe7..1544ded2 100644 --- a/src/systems/CMakeLists.txt +++ b/src/systems/CMakeLists.txt @@ -23,8 +23,8 @@ cmake_minimum_required(VERSION 3.15) # systems -add_subdirectory(data) add_subdirectory(isq) +add_subdirectory(isq-iec80000) add_subdirectory(isq-natural) add_subdirectory(si) add_subdirectory(si-cgs) @@ -38,8 +38,8 @@ add_subdirectory(si-us) # wrapper for all the systems add_library(mp-units-systems INTERFACE) target_link_libraries(mp-units-systems INTERFACE - mp-units::data mp-units::isq + mp-units::isq-iec80000 mp-units::isq-natural mp-units::si mp-units::si-cgs diff --git a/src/systems/data/include/units/data/bitrate.h b/src/systems/data/include/units/data/bitrate.h deleted file mode 100644 index af7e00be..00000000 --- a/src/systems/data/include/units/data/bitrate.h +++ /dev/null @@ -1,88 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include -#include -#include -#include - -namespace units::data { - -struct bit_per_second : unit {}; -struct dim_bitrate : derived_dimension, exponent> {}; - -struct kibibit_per_second : deduced_unit {}; -struct mebibit_per_second : deduced_unit {}; -struct gibibit_per_second : deduced_unit {}; -struct tebibit_per_second : deduced_unit {}; -struct pebibit_per_second : deduced_unit {}; - -struct kilobit_per_second : deduced_unit {}; -struct megabit_per_second : deduced_unit {}; -struct gigabit_per_second : deduced_unit {}; -struct terabit_per_second : deduced_unit {}; -struct petabit_per_second : deduced_unit {}; - -template -concept Bitrate = QuantityOf; - -template U, Representation Rep = double> -using bitrate = quantity; - -inline namespace literals { - -// bits -constexpr auto operator"" _q_b_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } -constexpr auto operator"" _q_Kib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } -constexpr auto operator"" _q_Mib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } -constexpr auto operator"" _q_Gib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } -constexpr auto operator"" _q_Tib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } -constexpr auto operator"" _q_Pib_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } - -constexpr auto operator"" _q_kb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } -constexpr auto operator"" _q_Mb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } -constexpr auto operator"" _q_Gb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } -constexpr auto operator"" _q_Tb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } -constexpr auto operator"" _q_Pb_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return bitrate(static_cast(l)); } - -} // namespace literals - -namespace references { - -inline constexpr auto b_per_s = reference{}; -inline constexpr auto Kib_per_s = reference{}; -inline constexpr auto Mib_per_s = reference{}; -inline constexpr auto Gib_per_s = reference{}; -inline constexpr auto Tib_per_s = reference{}; -inline constexpr auto Pib_per_s = reference{}; - -inline constexpr auto kb_per_s = reference{}; -inline constexpr auto Mb_per_s = reference{}; -inline constexpr auto Gb_per_s = reference{}; -inline constexpr auto Tb_per_s = reference{}; -inline constexpr auto Pb_per_s = reference{}; - -} // namespace references - -} // namespace units::data diff --git a/src/systems/data/include/units/data/information.h b/src/systems/data/include/units/data/information.h deleted file mode 100644 index 30298066..00000000 --- a/src/systems/data/include/units/data/information.h +++ /dev/null @@ -1,115 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace units::data { - -struct bit : named_unit {}; -struct kibibit : prefixed_unit {}; -struct mebibit : prefixed_unit {}; -struct gibibit : prefixed_unit {}; -struct tebibit : prefixed_unit {}; -struct pebibit : prefixed_unit {}; - -struct si_bit : alias_unit {}; -struct kilobit : prefixed_unit {}; -struct megabit : prefixed_unit {}; -struct gigabit : prefixed_unit {}; -struct terabit : prefixed_unit {}; -struct petabit : prefixed_unit {}; - -struct byte : named_scaled_unit {}; -struct kibibyte : prefixed_unit {}; -struct mebibyte : prefixed_unit {}; -struct gibibyte : prefixed_unit {}; -struct tebibyte : prefixed_unit {}; -struct pebibyte : prefixed_unit {}; - -struct dim_information : base_dimension<"information", bit> {}; - -template -concept Information = QuantityOf; - -template U, Representation Rep = double> -using information = quantity; - -inline namespace literals { - -// bits -constexpr auto operator"" _q_b(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_Kib(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_Mib(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_Gib(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_Tib(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_Pib(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } - -// bits (SI) -constexpr auto operator"" _q_kb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_Mb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_Gb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_Tb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_Pb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } - -// bytes -constexpr auto operator"" _q_B(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_KiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_MiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_GiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_TiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } -constexpr auto operator"" _q_PiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return information(static_cast(l)); } - -} // namespace literals - -namespace references { - -inline constexpr auto b = reference{}; - -inline constexpr auto Kib = reference{}; -inline constexpr auto Mib = reference{}; -inline constexpr auto Gib = reference{}; -inline constexpr auto Tib = reference{}; -inline constexpr auto Pib = reference{}; - -inline constexpr auto kb = reference{}; -inline constexpr auto Mb = reference{}; -inline constexpr auto Gb = reference{}; -inline constexpr auto Tb = reference{}; -inline constexpr auto Pb = reference{}; - -inline constexpr auto B = reference{}; -inline constexpr auto KiB = reference{}; -inline constexpr auto MiB = reference{}; -inline constexpr auto GiB = reference{}; -inline constexpr auto TiB = reference{}; -inline constexpr auto PiB = reference{}; - -} // namespace references - -} // namespace units::data diff --git a/src/systems/data/include/units/data/symbolrate.h b/src/systems/data/include/units/data/symbolrate.h deleted file mode 100644 index 4c47def1..00000000 --- a/src/systems/data/include/units/data/symbolrate.h +++ /dev/null @@ -1,62 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2021 Christoph Seitz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include -#include - -namespace units::data { - -struct baud : alias_unit {}; -struct kilobaud : prefixed_alias_unit {}; -struct megabaud : prefixed_alias_unit {}; -struct gigabaud : prefixed_alias_unit {}; -struct terabaud : prefixed_alias_unit {}; -struct petabaud : prefixed_alias_unit {}; - -template U, Representation Rep = double> -using symbolrate = quantity; - -inline namespace literals { - -constexpr auto operator"" _q_Bd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return symbolrate(static_cast(l)); } -constexpr auto operator"" _q_kBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return symbolrate(static_cast(l)); } -constexpr auto operator"" _q_MBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return symbolrate(static_cast(l)); } -constexpr auto operator"" _q_GBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return symbolrate(static_cast(l)); } -constexpr auto operator"" _q_TBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return symbolrate(static_cast(l)); } -constexpr auto operator"" _q_PBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return symbolrate(static_cast(l)); } - -} // namespace literals - -namespace references { - -inline constexpr auto Bd = reference{}; -inline constexpr auto kBd = reference{}; -inline constexpr auto MBd = reference{}; -inline constexpr auto GBd = reference{}; -inline constexpr auto TBd = reference{}; -inline constexpr auto PBd = reference{}; - -} // namespace references - -} // namespace units::data diff --git a/src/systems/data/CMakeLists.txt b/src/systems/isq-iec80000/CMakeLists.txt similarity index 96% rename from src/systems/data/CMakeLists.txt rename to src/systems/isq-iec80000/CMakeLists.txt index f386ca90..9f37c6f6 100644 --- a/src/systems/data/CMakeLists.txt +++ b/src/systems/isq-iec80000/CMakeLists.txt @@ -22,4 +22,4 @@ cmake_minimum_required(VERSION 3.15) -add_units_module(data mp-units::core) +add_units_module(isq-iec80000 mp-units::si) diff --git a/src/systems/data/include/units/data/prefixes.h b/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h similarity index 63% rename from src/systems/data/include/units/data/prefixes.h rename to src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h index a6c74d3c..e314d657 100644 --- a/src/systems/data/include/units/data/prefixes.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h @@ -24,15 +24,15 @@ #include -namespace units::data { +namespace units::isq::iec80000 { -struct prefix : prefix_family {}; +struct binary_prefix : prefix_family {}; -struct kibi : units::prefix {}; -struct mebi : units::prefix {}; -struct gibi : units::prefix {}; -struct tebi : units::prefix {}; -struct pebi : units::prefix {}; -struct exbi : units::prefix {}; +struct kibi : units::prefix {}; +struct mebi : units::prefix {}; +struct gibi : units::prefix {}; +struct tebi : units::prefix {}; +struct pebi : units::prefix {}; +struct exbi : units::prefix {}; -} // namespace units::data +} // namespace units::isq::iec80000 diff --git a/src/systems/data/include/units/data/data.h b/src/systems/isq-iec80000/include/units/isq/iec80000/iec80000.h similarity index 85% rename from src/systems/data/include/units/data/data.h rename to src/systems/isq-iec80000/include/units/isq/iec80000/iec80000.h index 22cdaf1a..f924bb2f 100644 --- a/src/systems/data/include/units/data/data.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/iec80000.h @@ -22,7 +22,7 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h b/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h new file mode 100644 index 00000000..ed06aa8f --- /dev/null +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h @@ -0,0 +1,74 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include +#include + +namespace units::isq::iec80000 { + +struct baud : alias_unit {}; +struct kilobaud : prefixed_alias_unit {}; +struct megabaud : prefixed_alias_unit {}; +struct gigabaud : prefixed_alias_unit {}; +struct terabaud : prefixed_alias_unit {}; +struct petabaud : prefixed_alias_unit {}; +struct exabaud : prefixed_alias_unit {}; +struct zettabaud : prefixed_alias_unit {}; +struct yottabaud : prefixed_alias_unit {}; + +// TODO alias_dimension +using dim_modulation_rate = si::dim_frequency; + +template U, Representation Rep = double> +using modulation_rate = quantity; + +inline namespace literals { + +constexpr auto operator"" _q_Bd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } +constexpr auto operator"" _q_kBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } +constexpr auto operator"" _q_MBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } +constexpr auto operator"" _q_GBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } +constexpr auto operator"" _q_TBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } +constexpr auto operator"" _q_PBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } +constexpr auto operator"" _q_EBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } +constexpr auto operator"" _q_ZBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } +constexpr auto operator"" _q_YBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } + +} // namespace literals + +namespace references { + +inline constexpr auto Bd = reference{}; +inline constexpr auto kBd = reference{}; +inline constexpr auto MBd = reference{}; +inline constexpr auto GBd = reference{}; +inline constexpr auto TBd = reference{}; +inline constexpr auto PBd = reference{}; +inline constexpr auto EBd = reference{}; +inline constexpr auto ZBd = reference{}; +inline constexpr auto YBd = reference{}; + +} // namespace references + +} // namespace units::isq::iec80000 diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h b/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h new file mode 100644 index 00000000..5bed9626 --- /dev/null +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h @@ -0,0 +1,161 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include +#include +#include +#include +#include + +namespace units::isq::iec80000 { + +struct bit : named_unit {}; +struct kilobit : prefixed_unit {}; +struct megabit : prefixed_unit {}; +struct gigabit : prefixed_unit {}; +struct terabit : prefixed_unit {}; +struct petabit : prefixed_unit {}; +struct exabit : prefixed_unit {}; +struct zettabit : prefixed_unit {}; +struct yottabit : prefixed_unit {}; + +struct binary_prefix_bit : alias_unit {}; +struct kibibit : prefixed_unit {}; +struct mebibit : prefixed_unit {}; +struct gibibit : prefixed_unit {}; +struct tebibit : prefixed_unit {}; +struct pebibit : prefixed_unit {}; +struct exbibit : prefixed_unit {}; + +struct byte : named_scaled_unit {}; +struct kilobyte : prefixed_unit {}; +struct megabyte : prefixed_unit {}; +struct gigabyte : prefixed_unit {}; +struct terabyte : prefixed_unit {}; +struct petabyte : prefixed_unit {}; +struct exabyte : prefixed_unit {}; +struct zettabyte : prefixed_unit {}; +struct yottabyte : prefixed_unit {}; + +struct binary_prefix_byte : alias_unit {}; +struct kibibyte : prefixed_unit {}; +struct mebibyte : prefixed_unit {}; +struct gibibyte : prefixed_unit {}; +struct tebibyte : prefixed_unit {}; +struct pebibyte : prefixed_unit {}; +// struct exbibyte : prefixed_unit {}; + +struct dim_storage_capacity : base_dimension<"M", byte> {}; + +template +concept StorageCapacity = QuantityOf; + +template U, Representation Rep = double> +using storage_capacity = quantity; + +inline namespace literals { + +// bits +constexpr auto operator"" _q_bit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } + +constexpr auto operator"" _q_kbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Mbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Gbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Tbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Pbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Ebit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Zbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Ybit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } + +constexpr auto operator"" _q_Kibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Mibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Gibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Tibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Pibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Eibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } + +// bytes +constexpr auto operator"" _q_B(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } + +constexpr auto operator"" _q_kB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_MB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_GB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_TB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_PB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_EB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_ZB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_YB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } + +constexpr auto operator"" _q_KiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_MiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_GiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_TiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_PiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +// constexpr auto operator"" _q_EiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } + +} // namespace literals + +namespace references { + +// bits +inline constexpr auto bit = reference{}; + +inline constexpr auto kbit = reference{}; +inline constexpr auto Mbit = reference{}; +inline constexpr auto Gbit = reference{}; +inline constexpr auto Tbit = reference{}; +inline constexpr auto Pbit = reference{}; +inline constexpr auto Ebit = reference{}; +inline constexpr auto Zbit = reference{}; +inline constexpr auto Ybit = reference{}; + +inline constexpr auto Kibit = reference{}; +inline constexpr auto Mibit = reference{}; +inline constexpr auto Gibit = reference{}; +inline constexpr auto Tibit = reference{}; +inline constexpr auto Pibit = reference{}; +inline constexpr auto Eibit = reference{}; + +// bytes +inline constexpr auto B = reference{}; + +inline constexpr auto kB = reference{}; +inline constexpr auto MB = reference{}; +inline constexpr auto GB = reference{}; +inline constexpr auto TB = reference{}; +inline constexpr auto PB = reference{}; +inline constexpr auto EB = reference{}; +inline constexpr auto ZB = reference{}; +inline constexpr auto YB = reference{}; + +inline constexpr auto KiB = reference{}; +inline constexpr auto MiB = reference{}; +inline constexpr auto GiB = reference{}; +inline constexpr auto TiB = reference{}; +inline constexpr auto PiB = reference{}; +// inline constexpr auto EiB = reference{}; + +} // namespace references + +} // namespace units::isq::iec80000 diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h b/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h new file mode 100644 index 00000000..9086906e --- /dev/null +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h @@ -0,0 +1,54 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include +#include +#include +#include + +namespace units::isq::iec80000 { + +struct erlang : named_unit {}; + +struct dim_traffic_intensity : base_dimension<"A", erlang> {}; + +template +concept TrafficIntensity = QuantityOf; + +template U, Representation Rep = double> +using traffic_intensity = quantity; + +inline namespace literals { + +constexpr auto operator"" _q_E(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return traffic_intensity(static_cast(l)); } + +} // namespace literals + +namespace references { + +inline constexpr auto E = reference{}; + +} // namespace references + +} // namespace units::isq::iec80000 diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h b/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h new file mode 100644 index 00000000..f5204e3c --- /dev/null +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h @@ -0,0 +1,64 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include +#include +#include +#include + +namespace units::isq::iec80000 { + +struct byte_per_second : unit {}; +struct dim_transfer_rate : derived_dimension, exponent> {}; + +struct kilobyte_per_second : deduced_unit {}; +struct megabyte_per_second : deduced_unit {}; +struct gigabyte_per_second : deduced_unit {}; +struct terabyte_per_second : deduced_unit {}; +struct petabyte_per_second : deduced_unit {}; +struct exabyte_per_second : deduced_unit {}; +struct zettabyte_per_second : deduced_unit {}; +struct yottabyte_per_second : deduced_unit {}; + +template +concept TransferRate = QuantityOf; + +template U, Representation Rep = double> +using transfer_rate = quantity; + +inline namespace literals { + +constexpr auto operator"" _q_B_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } +constexpr auto operator"" _q_kB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } +constexpr auto operator"" _q_MB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } +constexpr auto operator"" _q_GB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } +constexpr auto operator"" _q_TB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } +constexpr auto operator"" _q_PB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } +constexpr auto operator"" _q_EB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } +constexpr auto operator"" _q_ZB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } +constexpr auto operator"" _q_YB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } + +} // namespace literals + +} // namespace units::isq::iec80000 diff --git a/test/unit_test/runtime/CMakeLists.txt b/test/unit_test/runtime/CMakeLists.txt index 7610b9fc..08bace2f 100644 --- a/test/unit_test/runtime/CMakeLists.txt +++ b/test/unit_test/runtime/CMakeLists.txt @@ -26,7 +26,6 @@ find_package(Catch2 CONFIG REQUIRED) add_executable(unit_tests_runtime catch_main.cpp - digital_info_test.cpp math_test.cpp fmt_test.cpp fmt_units_test.cpp diff --git a/test/unit_test/runtime/digital_info_test.cpp b/test/unit_test/runtime/digital_info_test.cpp deleted file mode 100644 index 6cd0779a..00000000 --- a/test/unit_test/runtime/digital_info_test.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include -#include -#include -#include -#include - -using namespace units::data; - -TEST_CASE("operator<< on a data quantity", "[text][ostream]") -{ - std::stringstream stream; - - SECTION("quantity with a predefined unit and prefix") - { - SECTION("named unit") - { - stream << 64_q_B; - REQUIRE(stream.str() == "64 B"); - } - - SECTION("prefixed coherent unit") - { - stream << 256_q_Kib; - REQUIRE(stream.str() == "256 Kib"); - } - - SECTION("prefixed non-coherent unit") - { - stream << 1024_q_KiB; - REQUIRE(stream.str() == "1024 KiB"); - } - - SECTION("other unit matching prefix") - { - stream << 8_q_Kib * 8_q_Kib / 2_q_b; - REQUIRE(stream.str() == "32 Mib"); - } - SECTION("prefixed coherent unit (SI)") { - stream << 32_q_kb; - REQUIRE(stream.str() == "32 kb"); - } - } -} - -TEST_CASE("fmt::format on data unit symbols", "[text][fmt]") -{ - SECTION("symbolrate") - { - CHECK(fmt::format("{}", 1_q_Bd) == "1 Bd"); - CHECK(fmt::format("{}", 1_q_kBd) == "1 kBd"); - CHECK(fmt::format("{}", 1_q_MBd) == "1 MBd"); - CHECK(fmt::format("{}", 1_q_GBd) == "1 GBd"); - CHECK(fmt::format("{}", 1_q_TBd) == "1 TBd"); - } -} diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 52739764..886670cf 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -21,6 +21,7 @@ // SOFTWARE. #include "units/format.h" +#include "units/isq/iec80000/iec80000.h" #include "units/isq/si/si.h" #include "units/isq/si/iau/iau.h" #include "units/isq/si/imperial/imperial.h" @@ -30,11 +31,13 @@ #include using namespace units::isq::si; +using namespace units::isq::si::references; using namespace units::isq::si::international; using namespace units::isq::si::us; using namespace units::isq::si::iau; using namespace units::isq::si::imperial; using namespace units::isq::si::typographic; +using namespace units::isq::iec80000::references; TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]") { @@ -97,8 +100,8 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]") SECTION("density") { - CHECK(fmt::format("{}", 1_q_kg_per_m3) == "1 kg/m³"); - CHECK(fmt::format("{:%Q %Aq}", 1_q_kg_per_m3) == "1 kg/m^3"); + CHECK(fmt::format("{}", 1_q_kg_per_m3) == "1 kg/m³"); + CHECK(fmt::format("{:%Q %Aq}", 1_q_kg_per_m3) == "1 kg/m^3"); } SECTION("resistance") @@ -116,13 +119,13 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]") SECTION("voltage") { - CHECK(fmt::format("{}", 1_q_V) == "1 V"); - CHECK(fmt::format("{}", 1_q_mV) == "1 mV"); - CHECK(fmt::format("{}", 1_q_uV) == "1 µV"); - CHECK(fmt::format("{}", 1_q_nV) == "1 nV"); - CHECK(fmt::format("{}", 1_q_pV) == "1 pV"); + CHECK(fmt::format("{}", 1_q_V) == "1 V"); + CHECK(fmt::format("{}", 1_q_mV) == "1 mV"); + CHECK(fmt::format("{}", 1_q_uV) == "1 µV"); + CHECK(fmt::format("{}", 1_q_nV) == "1 nV"); + CHECK(fmt::format("{}", 1_q_pV) == "1 pV"); - CHECK(fmt::format("{:%Q %Aq}", 1_q_uV) == "1 uV"); + CHECK(fmt::format("{:%Q %Aq}", 1_q_uV) == "1 uV"); } SECTION("volume") @@ -310,6 +313,37 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]") CHECK(fmt::format("{}", 1_q_Nm_per_rad) == "1 N ⋅ m/rad"); } + SECTION("storage_capacity") + { + CHECK(fmt::format("{}", 1 * bit) == "1 bit"); + CHECK(fmt::format("{}", 1 * kbit) == "1 kbit"); + CHECK(fmt::format("{}", 1 * Tibit) == "1 Tibit"); + CHECK(fmt::format("{}", 1 * B) == "1 B"); + CHECK(fmt::format("{}", 1 * kB) == "1 kB"); + CHECK(fmt::format("{}", 1 * TiB) == "1 TiB"); + } + + SECTION("transfer_rate") + { + CHECK(fmt::format("{}", 1 * (B / s)) == "1 B/s"); + CHECK(fmt::format("{}", 1 * (kB / s)) == "1 kB/s"); + CHECK(fmt::format("{}", 1 * (TB / s)) == "1 TB/s"); + } + + SECTION("traffic_intesity") + { + CHECK(fmt::format("{}", 1 * E) == "1 E"); + } + + SECTION("modulation_rate") + { + using namespace units::isq::iec80000; + CHECK(fmt::format("{}", 1 * Bd) == "1 Bd"); + CHECK(fmt::format("{}", 1 * kBd) == "1 kBd"); + CHECK(fmt::format("{}", 1 * TBd) == "1 TBd"); + CHECK(fmt::format("{}", quantity_cast(4 / (2 * s))) == "2 Bd"); + } + SECTION("incoherent units with powers") { CHECK(fmt::format("{}", 1_q_mi * 1_q_mi * 1_q_mi) == "1 [15900351812136/3814697265625 × 10⁹] m³"); diff --git a/test/unit_test/static/CMakeLists.txt b/test/unit_test/static/CMakeLists.txt index 3be860ca..f3981ce4 100644 --- a/test/unit_test/static/CMakeLists.txt +++ b/test/unit_test/static/CMakeLists.txt @@ -44,11 +44,11 @@ add_library(unit_tests_static concepts_test.cpp custom_rep_test_min_expl.cpp custom_unit_test.cpp - data_test.cpp dimension_op_test.cpp dimensions_concepts_test.cpp fixed_string_test.cpp fps_test.cpp + iec80000_test.cpp kind_test.cpp math_test.cpp ratio_test.cpp diff --git a/test/unit_test/static/data_test.cpp b/test/unit_test/static/iec80000_test.cpp similarity index 58% rename from test/unit_test/static/data_test.cpp rename to test/unit_test/static/iec80000_test.cpp index 4a333ae5..5a524385 100644 --- a/test/unit_test/static/data_test.cpp +++ b/test/unit_test/static/iec80000_test.cpp @@ -20,31 +20,41 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include /* ************** DERIVED DIMENSIONS THAT INCLUDE UNITS WITH SPECIAL NAMES **************** */ namespace { -using namespace units::data; +using namespace units::isq::si::references; +using namespace units::isq::iec80000::references; // information -static_assert(1_q_B == 8_q_b); -static_assert(1024_q_b == 1_q_Kib); -static_assert(1024_q_B == 1_q_KiB); -static_assert(8 * 1024_q_b == 1_q_KiB); -static_assert(8 * 1_q_Kib == 1_q_KiB); +static_assert(1 * B == 8 * bit); +static_assert(1024 * bit == 1 * Kibit); +static_assert(1024 * B == 1 * KiB); +static_assert(8 * 1024 * bit == 1 * KiB); +static_assert(8 * 1 * Kibit == 1 * KiB); -static_assert(1_q_kb == 1000_q_b); -static_assert(2000_q_Mib == 2097152_q_kb); +static_assert(1 * kbit == 1000 * bit); +static_assert(2000 * Mibit == 2097152 * kbit); -static_assert(1_q_Kib == 1024_q_b); -static_assert(1_q_Mib == 1024_q_Kib); -static_assert(1_q_Gib == 1024_q_Mib); -static_assert(1_q_Tib == 1024_q_Gib); -static_assert(1_q_Pib == 1024_q_Tib); +static_assert(1 * Kibit == 1024 * bit); +static_assert(1 * Mibit == 1024 * Kibit); +static_assert(1 * Gibit == 1024 * Mibit); +static_assert(1 * Tibit == 1024 * Gibit); +static_assert(1 * Pibit == 1024 * Tibit); +static_assert(1 * Eibit == 1024 * Pibit); -// bitrate +// transfer rate + +static_assert(16 * B / (2 * s) == 8 * (B / s)); +static_assert(120 * kB / (2 * min) == 1000 * (B / s)); + +// modulation rate + +static_assert(12 / (2 * s) == 6 * Bd); +static_assert(6000 / (3 * s) == 2 * kBd); }