Skip to content

Commit

Permalink
test: uncommented some already supported cases
Browse files Browse the repository at this point in the history
Resolves #206
  • Loading branch information
mpusz committed May 11, 2021
1 parent 0174572 commit ae7aca5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
12 changes: 6 additions & 6 deletions test/unit_test/static/si_cgs_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,25 @@ namespace cgs_test {

// addition

// static_assert(100_q_cm + si::length<si::metre>(1) == si::length<si::metre>(2)); // should not compile (different dimensions)
// static_assert(si::length<si::metre>(1) + 100_q_cm == si::length<si::metre>(2)); // should not compile (different dimensions)
static_assert(100_q_cm + si::length<si::metre>(1) == si::length<si::metre>(2));
static_assert(si::length<si::metre>(1) + 100_q_cm == si::length<si::metre>(2));
static_assert(quantity_cast<si::length<si::metre>>(100_q_cm) + si::length<si::metre>(1) == si::length<si::metre>(2));
static_assert(si::length<si::metre>(1) + quantity_cast<si::length<si::metre>>(100_q_cm) == si::length<si::metre>(2));
static_assert(100_q_cm + quantity_cast<si::cgs::length<si::cgs::centimetre>>(si::length<si::metre>(1)) == 200_q_cm);
static_assert(quantity_cast<si::cgs::length<si::cgs::centimetre>>(si::length<si::metre>(1)) + 100_q_cm == 200_q_cm);

// substraction

// static_assert(500_q_cm - si::length<si::metre>(1) == si::length<si::metre>(4)); // should not compile (different dimensions)
// static_assert(si::length<si::metre>(5) - 100_q_cm == si::length<si::metre>(4)); // should not compile (different dimensions)
static_assert(500_q_cm - si::length<si::metre>(1) == si::length<si::metre>(4));
static_assert(si::length<si::metre>(5) - 100_q_cm == si::length<si::metre>(4));
static_assert(quantity_cast<si::length<si::metre>>(500_q_cm) - si::length<si::metre>(1) == si::length<si::metre>(4));
static_assert(si::length<si::metre>(5) - quantity_cast<si::length<si::metre>>(100_q_cm) == si::length<si::metre>(4));
static_assert(500_q_cm - quantity_cast<si::cgs::length<si::cgs::centimetre>>(si::length<si::metre>(1)) == 400_q_cm);
static_assert(quantity_cast<si::cgs::length<si::cgs::centimetre>>(si::length<si::metre>(5)) - 100_q_cm == 400_q_cm);

// multiplication

// static_assert(200_q_cm * si::length<si::metre>(2) == si::area<si::square_metre>(4)); // should not compile (unknown dimension)
// static_assert(200_q_cm * si::length<si::metre>(2) == si::area<si::square_metre>(4)); // TODO Add support for comparing of an unknown_dimension

static_assert(quantity_cast<si::dim_length>(200._q_cm) * si::length<si::metre>(2) == si::area<si::square_metre>(4));
static_assert(200._q_cm * quantity_cast<si::cgs::dim_length>(si::length<si::metre>(2)) == 40'000_q_cm2);
Expand All @@ -138,7 +138,7 @@ static_assert(200._q_cm * quantity_cast<si::cgs::dim_length>(si::length<si::metr

// division

// static_assert(si::area<si::square_metre>(4) / 200_q_cm == si::length<si::metre>(2)); // should not compile (unknown dimension)
// static_assert(si::area<si::square_metre>(4) / 200_q_cm == si::length<si::metre>(2)); // TODO Add support for comparing of an unknown_dimension

static_assert(si::area<si::square_metre>(4) / quantity_cast<si::length<si::metre>>(200_q_cm) == si::length<si::metre>(2));
static_assert(quantity_cast<si::cgs::area<si::cgs::square_centimetre>>(si::area<si::square_metre>(4)) / 200._q_cm == 200_q_cm);
Expand Down
14 changes: 7 additions & 7 deletions test/unit_test/static/si_fps_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@ using namespace units::isq::si::fps::references;

// addition

// static_assert(si::length<si::metre>(1) + 1 * ft == si::length<si::metre>(1.3048)); // should not compile (different dimensions)
// static_assert(1 * ft / 0.3048 + si::length<si::metre>(1) == si::length<si::metre>(1.3048)); // should not compile (different dimensions)
static_assert(si::length<si::metre>(1) + 1 * ft == si::length<si::metre>(1.3048));
static_assert(1 * ft + si::length<si::metre>(1) == si::length<si::metre>(1.3048));
static_assert(quantity_cast<si::length<si::metre>>(1. * ft / 0.3048) + si::length<si::metre>(1) == si::length<si::metre>(2)); // 1 m in ft + 1 m
static_assert(si::length<si::metre>(1) + quantity_cast<si::length<si::metre>>(1. * ft / 0.3048) == si::length<si::metre>(2)); // 1 m + 1 m in ft
static_assert(1 * ft + quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre>(0.3048)) == 2 * ft); // 1 ft + 1 ft in m
static_assert(quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre>(0.3048)) + 1 * ft == 2 * ft); // 1 ft in m + 1 ft

// substraction

// static_assert(1 * ft - si::length<si::metre>(1) == -si::length<si::metre>(0.6952)); // should not compile (different dimensions)
// static_assert(si::length<si::metre>(1) - 1 * ft == si::length<si::metre>(0.6952)); // should not compile (different dimensions)
static_assert(1 * ft - si::length<si::metre>(1) == -si::length<si::metre>(0.6952));
static_assert(si::length<si::metre>(1) - 1 * ft == si::length<si::metre>(0.6952));
static_assert(quantity_cast<si::length<si::metre>>(6. * ft) - si::length<si::metre>(1) > si::length<si::metre>(0.8287) &&
quantity_cast<si::length<si::metre>>(6. * ft) - si::length<si::metre>(1) < si::length<si::metre>(0.8289)); // 6 ft in m - 1 m = ... m
static_assert(si::length<si::metre>(5) - quantity_cast<si::length<si::metre>>(6 * ft) == si::length<si::metre>(3.1712)); // 5 m - 6 ft in m = ...
Expand All @@ -143,14 +143,14 @@ static_assert(quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre

// multiplication

// static_assert(2 * ft * si::length<si::metre>(2) == si::area<si::square_metre>(1.2192)); // should not compile (unknown dimension)
// static_assert(quantity_cast<si::length<si::metre>>(2. * ft) * si::length<si::metre>(2) == si::area<si::square_metre>(1.2192));
// static_assert(2 * ft * si::length<si::metre>(2) == si::area<si::square_metre>(1.2192)); // TODO Add support for comparing of an unknown_dimension
static_assert(quantity_cast<si::length<si::metre>>(2. * ft) * si::length<si::metre>(2) == si::area<si::square_metre>(1.2192));
static_assert(quantity_cast<si::length<si::metre>>(2. * ft) * si::length<si::metre>(0.6096) == si::area<si::square_metre>(0.371612160)); // 2 ft * 2 ft == 4 sq ft
static_assert(2. * ft * quantity_cast<si::fps::length<si::fps::foot>>(si::length<si::metre>(0.6096)) == 4._q_ft2);

// division

// static_assert(si::area<si::square_metre>(4) / 200_q_cm == si::length<si::metre>(2)); // should not compile (unknown dimension)
// static_assert(si::area<si::square_metre>(4) / 200_q_cm == si::length<si::metre>(2)); // TODO Add support for comparing of an unknown_dimension
static_assert(si::area<si::square_metre>(1.48644864) / quantity_cast<si::length<si::metre>>(4 * ft) == si::length<si::metre>(1.2192)); // 16 ft2 / 4 ft = 4 ft
static_assert(quantity_cast<si::fps::area<si::fps::square_foot>>(si::area<si::square_metre>(1.48644864)) / (4. * ft) == 4. * ft); // 16 ft2 / 4 ft = 4 ft

Expand Down
8 changes: 5 additions & 3 deletions test/unit_test/static/si_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,17 @@ static_assert(kilogray::symbol == "kGy");
static_assert(10_q_m / 5_q_s == 2_q_m_per_s);
static_assert(10 / 5_q_s * 1_q_m == 2_q_m_per_s);
static_assert(1_q_km / 1_q_s == 1000_q_m_per_s);
// static_assert(1_q_km / 1_q_h == 1_q_km_per_h); // should not compile
static_assert(1_q_km / 1_q_h == 1_q_km_per_h);
static_assert(1.0_q_km / 1_q_h == 1_q_km_per_h);
static_assert(1000.0_q_m / 3600.0_q_s == 1_q_km_per_h);

static_assert(2_q_km_per_h * 2_q_h == 4_q_km);
// static_assert(2_q_km_per_h * 15_q_min == 500_q_m); // should not compile
static_assert(2_q_km_per_h * 15_q_min == 500_q_m);
static_assert(2_q_km_per_h * 15.0_q_min == 500_q_m);
static_assert(2.0_q_km_per_h * 15_q_min == 500_q_m);

static_assert(2_q_km / 2_q_km_per_h == 1_q_h);
// static_assert(2000_q_m / 2_q_km_per_h == 1_q_h); // should not compile
static_assert(2000_q_m / 2_q_km_per_h == 1_q_h);
static_assert(quantity_cast<kilometre>(2000_q_m) / 2_q_km_per_h == 1_q_h);

static_assert(detail::unit_text<dim_speed, metre_per_second>() == "m/s");
Expand Down Expand Up @@ -382,6 +382,8 @@ static_assert(1_q_J_per_mol * 1_q_mol_per_m3 * 1_q_m3 == 1_q_N * 1_q_m);
static_assert(detail::unit_text<dim_molar_energy, joule_per_mole>() == "J/mol");

// angular velocity

static_assert(1_q_rad / 1_q_s == 1_q_rad_per_s);
static_assert(detail::unit_text<dim_angular_velocity, radian_per_second>() == basic_symbol_text("ω", "w"));

} // namespace

0 comments on commit ae7aca5

Please sign in to comment.