refactor: the rest of the systems refactored for V2
This commit is contained in:
1 parent
a9c190a7bf
commit
97da55edfa
62 files changed
+1179
-3442
No files matched your search
@@ -22,12 +22,12 @@
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/matchers/catch_matchers_exception.hpp>
|
||||
#include <units/cgs/cgs.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/format.h>
|
||||
#include <units/isq/mechanics.h>
|
||||
#include <units/isq/space_and_time.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <units/si/cgs/cgs.h>
|
||||
#include <units/si/si.h>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
|
||||
@@ -46,7 +46,9 @@ add_library(
|
||||
# dimensions_concepts_test.cpp
|
||||
fixed_string_test.cpp
|
||||
# fps_test.cpp
|
||||
# iec80000_test.cpp
|
||||
hep_test.cpp
|
||||
iec80000_test.cpp
|
||||
imperial_test.cpp
|
||||
isq_test.cpp
|
||||
isq_angle_test.cpp
|
||||
# kind_test.cpp
|
||||
@@ -59,12 +61,11 @@ add_library(
|
||||
reference_test.cpp
|
||||
# si_cgs_test.cpp
|
||||
# si_fps_test.cpp
|
||||
# si_hep_test.cpp
|
||||
# si_test.cpp
|
||||
symbol_text_test.cpp
|
||||
type_list_test.cpp
|
||||
unit_test.cpp
|
||||
# us_test.cpp
|
||||
usc_test.cpp
|
||||
)
|
||||
|
||||
# if(NOT ${projectPrefix}LIBCXX)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
// Copyright (c) 2021 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
|
||||
@@ -20,36 +20,28 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/isq/si/international/length.h>
|
||||
#include <units/isq/si/international/speed.h>
|
||||
#include <units/isq/si/length.h>
|
||||
#include <units/isq/si/time.h>
|
||||
#include <units/unit.h>
|
||||
#include <units/hep/hep.h>
|
||||
#include <units/isq/mechanics.h>
|
||||
#include <units/isq/space_and_time.h>
|
||||
#include <units/si/si.h>
|
||||
|
||||
template<class T>
|
||||
requires units::is_scalar<T>
|
||||
inline constexpr bool units::is_vector<T> = true;
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::isq::si;
|
||||
using namespace units::isq::si::international;
|
||||
using namespace units::hep::unit_symbols;
|
||||
using namespace units::si::unit_symbols;
|
||||
|
||||
/* ************** BASE DIMENSIONS **************** */
|
||||
// mass
|
||||
static_assert(isq::mass[eV / c2](1'000) == isq::mass[keV / c2](1));
|
||||
|
||||
// length
|
||||
// momentum
|
||||
static_assert(isq::momentum[eV / c](1'000'000) == isq::momentum[MeV / c](1));
|
||||
|
||||
static_assert(1_q_yd == 0.9144_q_m);
|
||||
static_assert(1_q_yd == 3_q_ft);
|
||||
static_assert(1_q_ft == 12_q_in);
|
||||
static_assert(1_q_mi == 1760_q_yd);
|
||||
|
||||
static_assert(5_q_in + 8_q_cm == 207_q_mm);
|
||||
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */
|
||||
|
||||
// speed
|
||||
|
||||
static_assert(10.0_q_mi / 2_q_h == 5_q_mi_per_h);
|
||||
|
||||
static_assert(mile_per_hour::symbol == "mi/h");
|
||||
// area
|
||||
static_assert(isq::area[b](1e28) == isq::area[m2](1.));
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,80 @@
|
||||
// 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 <units/imperial/imperial.h>
|
||||
#include <units/isq/space_and_time.h>
|
||||
#include <units/si/unit_symbols.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::imperial;
|
||||
using namespace units::imperial::unit_symbols;
|
||||
|
||||
/* ************** BASE DIMENSIONS **************** */
|
||||
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Length
|
||||
|
||||
// International
|
||||
static_assert(isq::length[twip](17'280) == isq::length[ft](1));
|
||||
static_assert(isq::length[th](12'000) == isq::length[ft](1));
|
||||
static_assert(isq::length[Bc](3) == isq::length[th](1'000));
|
||||
static_assert(isq::length[in](1) == isq::length[Bc](3));
|
||||
static_assert(isq::length[hh](1) == isq::length[in](4));
|
||||
static_assert(isq::length[ft](1) == isq::length[hh](3));
|
||||
static_assert(isq::length[yd](1) == isq::length[ft](3));
|
||||
static_assert(isq::length[ch](1) == isq::length[yd](22));
|
||||
static_assert(isq::length[fur](1) == isq::length[ch](10));
|
||||
static_assert(isq::length[mi](1) == isq::length[fur](8));
|
||||
static_assert(isq::length[le](1) == isq::length[mi](3));
|
||||
|
||||
// International Nautical
|
||||
static_assert(isq::length[cb](1) == isq::length[ftm](100));
|
||||
static_assert(isq::length[nmi](1) == isq::length[cb](10));
|
||||
|
||||
// survey
|
||||
static_assert(isq::length[li](100) == isq::length[ch](1));
|
||||
static_assert(isq::length[rd](1) == isq::length[li](25));
|
||||
|
||||
// Area
|
||||
static_assert(isq::area[perch](1) == isq::length[rd](1) * isq::length[rd](1));
|
||||
static_assert(isq::area[rood](1) == isq::length[fur](1) * isq::length[rd](1));
|
||||
static_assert(isq::area[acre](1) == isq::length[fur](1) * isq::length[ch](1));
|
||||
|
||||
// Volume
|
||||
static_assert(isq::volume[fl_oz](20) == isq::volume[pt](1));
|
||||
static_assert(isq::volume[gi](1) == isq::volume[fl_oz](5));
|
||||
static_assert(isq::volume[pt](1) == isq::volume[fl_oz](20));
|
||||
static_assert(isq::volume[qt](1) == isq::volume[pt](2));
|
||||
static_assert(isq::volume[gal](1) == isq::volume[pt](8));
|
||||
|
||||
// Mass
|
||||
static_assert(isq::mass[gr](7'000) == isq::mass[lb](1));
|
||||
static_assert(isq::mass[dr](256) == isq::mass[lb](1));
|
||||
static_assert(isq::mass[oz](1) == isq::mass[dr](16));
|
||||
static_assert(isq::mass[lb](1) == isq::mass[oz](16));
|
||||
static_assert(isq::mass[st](1) == isq::mass[lb](14));
|
||||
static_assert(isq::mass[qr](1) == isq::mass[st](2));
|
||||
static_assert(isq::mass[cwt](1) == isq::mass[lb](112));
|
||||
static_assert(isq::mass[t](1) == isq::mass[cwt](20));
|
||||
|
||||
} // namespace
|
||||
@@ -1,73 +0,0 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2021 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 <units/isq/si/area.h>
|
||||
#include <units/isq/si/hep/area.h>
|
||||
#include <units/isq/si/hep/energy.h>
|
||||
#include <units/isq/si/hep/mass.h>
|
||||
#include <units/isq/si/hep/momentum.h>
|
||||
#include <units/isq/si/length.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units::isq;
|
||||
|
||||
template<units::Quantity Q>
|
||||
inline constexpr units::ratio quantity_ratio = units::as_ratio(units::detail::quantity_magnitude<Q>);
|
||||
|
||||
static_assert(quantity_ratio<si::length<si::metre>> == units::ratio(1));
|
||||
|
||||
// mass
|
||||
static_assert(si::hep::mass<si::hep::eV_per_c2>(1'000) == si::hep::mass<si::hep::keV_per_c2>(1));
|
||||
static_assert(si::hep::mass<si::hep::eV_per_c2>(1'000) == si::mass<si::hep::keV_per_c2>(1));
|
||||
static_assert(si::mass<si::hep::eV_per_c2>(1'000) == si::hep::mass<si::hep::keV_per_c2>(1));
|
||||
|
||||
// momentum
|
||||
static_assert(si::hep::momentum<si::hep::eV_per_c>(1'000'000) == si::hep::momentum<si::hep::MeV_per_c>(1));
|
||||
|
||||
// area
|
||||
static_assert(si::area<si::hep::barn>(1e28) == si::area<si::square_metre>(1));
|
||||
// static_assert(si::area<si::hep::barn>(1) == si::area<si::square_metre>(1e-28)); // numeric rounding issues on some
|
||||
// platforms
|
||||
|
||||
|
||||
namespace hep_literal_test {
|
||||
|
||||
using namespace units::isq::si::hep::literals;
|
||||
|
||||
static_assert(si::hep::energy<si::hep::eV>(1'000) == 1_q_keV);
|
||||
static_assert(si::hep::energy<si::hep::eV>(1'000'000) == 1_q_MeV);
|
||||
|
||||
static_assert(si::hep::mass<si::hep::eV_per_c2>(1'000) == 1_q_keV_per_c2);
|
||||
static_assert(si::hep::mass<si::hep::eV_per_c2>(1'000'000) == 1_q_MeV_per_c2);
|
||||
|
||||
static_assert(si::hep::momentum<si::hep::eV_per_c>(1'000) == 1_q_keV_per_c);
|
||||
static_assert(si::hep::momentum<si::hep::eV_per_c>(1'000'000) == 1_q_MeV_per_c);
|
||||
|
||||
// static_assert(si::area<si::square_metre, long double>(1e-28L) == 1_q_b); // numeric rounding issues on some platforms
|
||||
// static_assert(si::hep::area<si::square_yoctometre, long double>(1e-4L) == 1_q_b); // numeric rounding issues on some
|
||||
// platforms
|
||||
static_assert(si::area<si::square_metre>(1e-43) == 1_q_fb);
|
||||
|
||||
} // namespace hep_literal_test
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,121 @@
|
||||
// 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 <units/isq/space_and_time.h>
|
||||
#include <units/si/unit_symbols.h>
|
||||
#include <units/usc/usc.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::usc;
|
||||
using namespace units::usc::unit_symbols;
|
||||
|
||||
/* ************** BASE DIMENSIONS **************** */
|
||||
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Length
|
||||
|
||||
// International
|
||||
static_assert(isq::length[twip](20) == isq::length[p](1));
|
||||
static_assert(isq::length[mil](1000) == isq::length[in](1));
|
||||
static_assert(isq::length[p](72) == isq::length[in](1));
|
||||
static_assert(isq::length[P](1) == isq::length[p](12));
|
||||
static_assert(isq::length[in](1) == isq::length[P](6));
|
||||
static_assert(isq::length[ft](1) == isq::length[in](12));
|
||||
static_assert(isq::length[yd](1) == isq::length[ft](3));
|
||||
static_assert(isq::length[mi](1) == isq::length[ft](5280));
|
||||
static_assert(isq::length[le](1) == isq::length[yd](5280));
|
||||
|
||||
// International Nautical
|
||||
static_assert(isq::length[ftm](1) == isq::length[yd](2));
|
||||
static_assert(isq::length[cb](1) == isq::length[ftm](120));
|
||||
static_assert(isq::length[nmi](1) == isq::length[si::metre](1852));
|
||||
|
||||
// US survey
|
||||
UNITS_DIAGNOSTIC_PUSH
|
||||
UNITS_DIAGNOSTIC_IGNORE_DEPRECATED
|
||||
static_assert(isq::length[us_ft](3937) == isq::length[si::metre](1200));
|
||||
static_assert(isq::length[us_mi](3937) == isq::length[si::kilo<si::metre>](6336));
|
||||
UNITS_DIAGNOSTIC_POP
|
||||
|
||||
static_assert(isq::length[li](50) == isq::length[ft](33));
|
||||
static_assert(isq::length[rd](1) == isq::length[li](25));
|
||||
static_assert(isq::length[ch](1) == isq::length[rd](4));
|
||||
static_assert(isq::length[fur](1) == isq::length[ch](10));
|
||||
static_assert(isq::length[lea](1) == isq::length[mi](3));
|
||||
|
||||
static_assert(isq::length[survey1893::link](50) == isq::length[survey1893::us_survey_foot](33));
|
||||
static_assert(isq::length[survey1893::us_survey_foot](3937) == isq::length[si::metre](1200));
|
||||
static_assert(isq::length[survey1893::rod](1) == isq::length[survey1893::link](25));
|
||||
static_assert(isq::length[survey1893::chain](1) == isq::length[survey1893::rod](4));
|
||||
static_assert(isq::length[survey1893::furlong](1) == isq::length[survey1893::chain](10));
|
||||
static_assert(isq::length[survey1893::us_survey_mile](1) == isq::length[survey1893::furlong](8));
|
||||
static_assert(isq::length[survey1893::league](1) == isq::length[survey1893::us_survey_mile](3));
|
||||
|
||||
// Area
|
||||
// static_assert(isq::area[square<survey1893::us_survey_foot>](1) == isq::area[square<inch>](144));
|
||||
static_assert(isq::area[square<survey1893::chain>](1) == isq::area[square<survey1893::us_survey_foot>](4356));
|
||||
static_assert(isq::area[acre](1) == isq::area[square<survey1893::us_survey_foot>](43560));
|
||||
static_assert(isq::area[section](1) == isq::area[square<survey1893::us_survey_mile>](1));
|
||||
|
||||
// Volume
|
||||
static_assert(isq::volume[cubic<foot>](1) == isq::volume[cubic<inch>](1'728));
|
||||
static_assert(isq::volume[cubic<yard>](1) == isq::volume[cubic<foot>](27));
|
||||
static_assert(isq::volume[acre * survey1893::us_survey_foot](1) ==
|
||||
isq::volume[cubic<survey1893::us_survey_foot>](43'560));
|
||||
|
||||
// Fluid volume
|
||||
static_assert(isq::volume[fl_dr](1) == isq::volume[min](60));
|
||||
static_assert(isq::volume[tsp](1) == isq::volume[min](80));
|
||||
static_assert(isq::volume[tbsp](1) == isq::volume[tsp](3));
|
||||
static_assert(isq::volume[fl_oz](1) == isq::volume[tbsp](2));
|
||||
static_assert(isq::volume[jig](1) == isq::volume[tbsp](3));
|
||||
static_assert(isq::volume[gi](1) == isq::volume[fl_oz](4));
|
||||
static_assert(isq::volume[c](1) == isq::volume[gi](2));
|
||||
static_assert(isq::volume[pt](1) == isq::volume[c](2));
|
||||
static_assert(isq::volume[qt](1) == isq::volume[pt](2));
|
||||
static_assert(isq::volume[pot](1) == isq::volume[qt](2));
|
||||
static_assert(isq::volume[gal](1) == isq::volume[qt](4));
|
||||
static_assert(isq::volume[bbl](2) == isq::volume[gal](63));
|
||||
static_assert(isq::volume[oil_barrel](3) == isq::volume[bbl](4));
|
||||
static_assert(isq::volume[hogshead](2) == isq::volume[oil_barrel](3));
|
||||
|
||||
// Dry volume
|
||||
static_assert(isq::volume[dry_qt](1) == isq::volume[dry_pt](2));
|
||||
static_assert(isq::volume[dry_gal](1) == isq::volume[dry_qt](4));
|
||||
static_assert(isq::volume[pk](1) == isq::volume[dry_gal](2));
|
||||
static_assert(isq::volume[bu](1) == isq::volume[pk](4));
|
||||
static_assert(isq::volume[dry_bbl](1) == isq::volume[cubic<inch>](7056));
|
||||
|
||||
// Mass
|
||||
static_assert(isq::mass[gr](7'000) == isq::mass[lb](1));
|
||||
static_assert(isq::mass[dr](32) == isq::mass[gr](875));
|
||||
static_assert(isq::mass[oz](1) == isq::mass[dr](16));
|
||||
static_assert(isq::mass[lb](1) == isq::mass[oz](16));
|
||||
static_assert(isq::mass[qr](1) == isq::mass[lb](25));
|
||||
static_assert(isq::mass[cwt](1) == isq::mass[qr](4));
|
||||
static_assert(isq::mass[t](1) == isq::mass[cwt](20));
|
||||
static_assert(isq::mass[dwt](1) == isq::mass[gr](24));
|
||||
static_assert(isq::mass[oz_t](1) == isq::mass[dwt](20));
|
||||
static_assert(isq::mass[lb_t](1) == isq::mass[oz_t](12));
|
||||
|
||||
} // namespace
|
||||
Reference in new issue
Block a user