diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-23 00:32:38 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-23 00:32:38 +0100 |
| commit | 0fa623093366351ad47583f47add6e51f56a56d8 (patch) | |
| tree | 3eaaa64f5c9b88798d2b971d2810f85cc3e06cd6 /nihil.ucl/tests/real.cc | |
| parent | 8cbb82a1f6eb6605a4615d30922b777e7bf1e4d8 (diff) | |
| download | nihil-0fa623093366351ad47583f47add6e51f56a56d8.tar.gz nihil-0fa623093366351ad47583f47add6e51f56a56d8.tar.bz2 | |
nihil.ucl: improve tests
Diffstat (limited to 'nihil.ucl/tests/real.cc')
| -rw-r--r-- | nihil.ucl/tests/real.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/nihil.ucl/tests/real.cc b/nihil.ucl/tests/real.cc index 4bd9b3f..b11c113 100644 --- a/nihil.ucl/tests/real.cc +++ b/nihil.ucl/tests/real.cc @@ -2,13 +2,32 @@ * This source code is released into the public domain. */ +#include <concepts> #include <string> #include <catch2/catch_test_macros.hpp> #include <catch2/matchers/catch_matchers_floating_point.hpp> +#include <ucl.h> import nihil.ucl; +TEST_CASE("ucl: real: invariants", "[ucl]") +{ + using namespace nihil::ucl; + + static_assert(std::same_as<double, real::contained_type>); + REQUIRE(real::ucl_type == object_type::real); + REQUIRE(static_cast<::ucl_type>(real::ucl_type) == UCL_FLOAT); + + static_assert(std::destructible<real>); + static_assert(std::default_initializable<real>); + static_assert(std::move_constructible<real>); + static_assert(std::copy_constructible<real>); + static_assert(std::equality_comparable<real>); + static_assert(std::totally_ordered<real>); + static_assert(std::swappable<real>); +} + TEST_CASE("ucl: real: construct", "[ucl]") { auto obj = nihil::ucl::real(42.1); @@ -22,6 +41,19 @@ TEST_CASE("ucl: real: default construct", "[ucl]") REQUIRE(i == 0); } +TEST_CASE("ucl: real: swap", "[ucl]") +{ + // do not add using namespace nihil::ucl + + auto r1 = nihil::ucl::real(1); + auto r2 = nihil::ucl::real(2); + + swap(r1, r2); + + REQUIRE(r1 == 2.); + REQUIRE(r2 == 1.); +} + TEST_CASE("ucl: real: operator==", "[ucl]") { auto i = nihil::ucl::real(42.5); |
