// 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 "test_tools.h" #include "units/unit.h" #include "units/bits/equivalent.h" #include "units/physical/si/prefixes.h" namespace { using namespace units; using namespace units::physical; struct metre : named_unit {}; struct centimetre : prefixed_unit {}; struct kilometre : prefixed_unit {}; struct yard : named_scaled_unit {}; struct foot : named_scaled_unit {}; struct dim_length : base_dimension<"length", metre> {}; struct second : named_unit {}; struct hour : named_scaled_unit {}; struct dim_time : base_dimension<"time", second> {}; struct kelvin : named_unit {}; #if !COMP_MSVC static_assert([](P) { return !requires { typename prefixed_unit; }; }(si::kilo{})); // no prefix allowed #endif struct metre_per_second : unit {}; struct dim_speed : derived_dimension, units::exponent> {}; struct kilometre_per_hour : deduced_unit {}; static_assert(equivalent); static_assert(equivalent); static_assert(compare>, metre>); static_assert(compare>, centimetre>); static_assert(compare>, yard>); static_assert(compare>, foot>); static_assert(compare>, kilometre_per_hour>); #if !COMP_MSVC static_assert([]() { return !requires { typename scaled_unit; }; }.template operator()()); // negative unit ratio #endif static_assert(centimetre::symbol == "cm"); static_assert(kilometre::symbol == "km"); static_assert(kilometre_per_hour::symbol == "km/h"); } // namespace