From 639b270eed81f7c2627d810057d188e2e8ee67f9 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sun, 22 Jun 2025 18:18:44 +0100 Subject: nihil.ucl: improve construction and comparison --- nihil.ucl/tests/real.cc | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'nihil.ucl/tests/real.cc') diff --git a/nihil.ucl/tests/real.cc b/nihil.ucl/tests/real.cc index 275684a..d97e767 100644 --- a/nihil.ucl/tests/real.cc +++ b/nihil.ucl/tests/real.cc @@ -16,16 +16,32 @@ TEST_CASE("ucl: real: construct", "[ucl]") Catch::Matchers::WithinRel(42.1)); } -TEST_CASE("ucl: real: compare", "[ucl]") +TEST_CASE("ucl: real: default construct", "[ucl]") { - auto i = nihil::ucl::real(42); + auto i = nihil::ucl::real(); + REQUIRE(i == 0); +} + +TEST_CASE("ucl: real: operator==", "[ucl]") +{ + auto i = nihil::ucl::real(42.5); + + REQUIRE(i == 42.5); + REQUIRE(i == nihil::ucl::real(42.5)); - REQUIRE(i == nihil::ucl::real(42)); + REQUIRE(i != 1); REQUIRE(i != nihil::ucl::real(1)); - REQUIRE((i == 42) == true); +} + +TEST_CASE("ucl: real: operator<=>", "[ucl]") +{ + auto i = nihil::ucl::real(42.5); + + REQUIRE(i < 43); + REQUIRE(i < nihil::ucl::real(43)); - REQUIRE(i > nihil::ucl::real(40)); - REQUIRE(i > 40); + REQUIRE(i > 1); + REQUIRE(i > nihil::ucl::real(1)); } TEST_CASE("ucl: real: parse", "[ucl]") -- cgit v1.2.3