From 1d991b79ccd64556f945e57db5f9009ecf3d590c Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Fri, 15 Dec 2023 11:50:33 -0500 Subject: [PATCH] Print unit labels if test fails --- au/quantity_test.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/au/quantity_test.cc b/au/quantity_test.cc index 2c51bd5a..553ce3eb 100644 --- a/au/quantity_test.cc +++ b/au/quantity_test.cc @@ -33,10 +33,16 @@ constexpr auto miles = QuantityMaker{}; struct Inches : decltype(Feet{} / mag<12>()) {}; constexpr auto inches = QuantityMaker{}; -struct Yards : decltype(Feet{} * mag<3>()) {}; +struct Yards : decltype(Feet{} * mag<3>()) { + static constexpr const char label[] = "yd"; +}; +constexpr const char Yards::label[]; constexpr auto yards = QuantityMaker{}; -struct Meters : decltype(Inches{} * mag<100>() / mag<254>() * mag<100>()) {}; +struct Meters : decltype(Inches{} * mag<100>() / mag<254>() * mag<100>()) { + static constexpr const char label[] = "m"; +}; +constexpr const char Meters::label[]; static constexpr QuantityMaker meters{}; static_assert(are_units_quantity_equivalent(Centi{} * mag<254>(), Inches{} * mag<100>()), "Double-check this ad hoc definition of meters");