From 7f5c394ca54f82a57d10ae29263e561b9f9288f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:31:05 +0200 Subject: [PATCH] Complete missing testcase --- nano/core_test/numbers.cpp | 7 ++++++- nano/lib/numbers.hpp | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/nano/core_test/numbers.cpp b/nano/core_test/numbers.cpp index 7d939ad32..1ffe78808 100644 --- a/nano/core_test/numbers.cpp +++ b/nano/core_test/numbers.cpp @@ -1,5 +1,5 @@ +#include #include -#include #include @@ -453,6 +453,11 @@ TEST (uint256_union, operator_less_than) test_union_operator_less_than (); } +TEST (uint256_union, operator_greater_than) +{ + test_union_operator_greater_than (); +} + TEST (uint64_t, parse) { uint64_t value0 (1); diff --git a/nano/lib/numbers.hpp b/nano/lib/numbers.hpp index c637e1594..71856e3b0 100644 --- a/nano/lib/numbers.hpp +++ b/nano/lib/numbers.hpp @@ -13,6 +13,7 @@ namespace nano using uint128_t = boost::multiprecision::uint128_t; using uint256_t = boost::multiprecision::uint256_t; using uint512_t = boost::multiprecision::uint512_t; + // SI dividers nano::uint128_t const Knano_ratio = nano::uint128_t ("1000000000000000000000000000000000"); // 10^33 = 1000 nano nano::uint128_t const nano_ratio = nano::uint128_t ("1000000000000000000000000000000"); // 10^30 = 1 nano @@ -113,6 +114,10 @@ inline bool operator< (nano::uint256_union const & lhs, nano::uint256_union cons { return std::memcmp (lhs.bytes.data (), rhs.bytes.data (), 32) < 0; } +inline bool operator> (nano::uint256_union const & lhs, nano::uint256_union const & rhs) +{ + return std::memcmp (lhs.bytes.data (), rhs.bytes.data (), 32) > 0; +} static_assert (std::is_nothrow_move_constructible::value, "uint256_union should be noexcept MoveConstructible"); class link;