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/integer.cc | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'nihil.ucl/tests/integer.cc') diff --git a/nihil.ucl/tests/integer.cc b/nihil.ucl/tests/integer.cc index da119e6..c7db851 100644 --- a/nihil.ucl/tests/integer.cc +++ b/nihil.ucl/tests/integer.cc @@ -10,20 +10,36 @@ import nihil.ucl; TEST_CASE("ucl: integer: construct", "[ucl]") { - auto obj = nihil::ucl::integer(42); - REQUIRE(object_cast(obj).value() == 42); + auto i = nihil::ucl::integer(42); + REQUIRE(i == 42); } -TEST_CASE("ucl: integer: compare", "[ucl]") +TEST_CASE("ucl: integer: default construct", "[ucl]") +{ + auto i = nihil::ucl::integer(); + REQUIRE(i == 0); +} + +TEST_CASE("ucl: integer: operator==", "[ucl]") { auto i = nihil::ucl::integer(42); + REQUIRE(i == 42); REQUIRE(i == nihil::ucl::integer(42)); + + REQUIRE(i != 1); REQUIRE(i != nihil::ucl::integer(1)); - REQUIRE((i == 42) == true); +} + +TEST_CASE("ucl: integer: operator<=>", "[ucl]") +{ + auto i = nihil::ucl::integer(42); + + REQUIRE(i < 43); + REQUIRE(i < nihil::ucl::integer(43)); - REQUIRE(i > nihil::ucl::integer(40)); - REQUIRE(i > 40); + REQUIRE(i > 1); + REQUIRE(i > nihil::ucl::integer(1)); } TEST_CASE("ucl: parse: integer", "[ucl]") -- cgit v1.2.3