Files
mp-units/test/static/isq_angle_test.cpp
T
Mateusz Pusz dd5854a965 refactor(test): drop the legacy character enum from the test suite
Replace `using enum quantity_character_legacy` plus bare character names in the ISQ/HEP
tests with local `quantity_character` constants (`scalar`, `complex_scalar`, `vector`,
`tensor`) built from `quantity_tensor_order` / `quantity_field`, and switch the
`RepresentationOf` / `QUANTITY_SPEC_` character arguments in the concept and quantity-spec
tests to the bare-axis spelling. `real_scalar` is renamed to `scalar` for consistency with
the order-named constants. `apparent_power` (derived from the complex `complex_power`)
pins `quantity_field::real`, matching the library definition.

This removes the final legacy-enum usage from the repository.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 00:10:20 +02:00

63 lines
3.1 KiB
C++

// 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 <mp-units/systems/isq_angle.h>
#include <mp-units/systems/si.h>
namespace {
using namespace mp_units;
using namespace mp_units::si::unit_symbols;
using namespace mp_units::angular::unit_symbols;
using mp_units::angular::unit_symbols::rad;
using mp_units::angular::unit_symbols::sr;
inline constexpr quantity_character scalar{quantity_tensor_order::scalar};
inline constexpr quantity_character vector{quantity_tensor_order::vector};
inline constexpr quantity_character tensor{quantity_tensor_order::tensor};
[[nodiscard]] consteval bool verify(QuantitySpec auto q, quantity_character ch, Unit auto... units)
{
return q.character == ch && (... && requires { q[units]; });
}
static_assert(verify(isq_angle::cotes_angle_constant, scalar, rad));
static_assert(verify(isq_angle::angular_measure, scalar, rad));
static_assert(verify(isq_angle::rotational_displacement, scalar, rad));
static_assert(verify(isq_angle::angular_displacement, scalar, rad));
static_assert(verify(isq_angle::solid_angular_measure, scalar, sr));
static_assert(verify(isq_angle::angular_velocity, vector, rad / s));
static_assert(verify(isq_angle::angular_acceleration, vector, rad / s2));
static_assert(verify(isq_angle::rotation, scalar, rad));
static_assert(verify(isq_angle::angular_frequency, scalar, rad / s));
static_assert(verify(isq_angle::angular_repetency, scalar, rad / m));
static_assert(verify(isq_angle::angular_wavenumber, scalar, rad / m));
static_assert(verify(isq_angle::phase_coefficient, scalar, rad / m));
static_assert(verify(isq_angle::propagation_coefficient, scalar, rad / m));
static_assert(verify(isq_angle::moment_of_inertia, tensor, kg* m2 / rad2));
static_assert(verify(isq_angle::angular_momentum, vector, J* s / rad));
static_assert(verify(isq_angle::moment_of_force, vector, J / rad));
static_assert(verify(isq_angle::torque, scalar, J / rad));
static_assert(verify(isq_angle::angular_impulse, vector, J* s / rad));
static_assert(verify(isq_angle::loss_angle, scalar, rad));
} // namespace