diff options
| author | Alexander Blair <snipa@jagtech.io> | 2020-08-16 12:53:50 -0700 |
|---|---|---|
| committer | Alexander Blair <snipa@jagtech.io> | 2020-08-16 12:53:50 -0700 |
| commit | 10ad0d7eb274bcbad064eaa0de0483d6f94231d3 (patch) | |
| tree | ba61cb2927188da0b873094a3f438b1514bacdc0 /tests | |
| parent | 01b512f3a91f2080f4fae0abfd19f3e0e1dc53e9 (diff) | |
| parent | 85efc88c1edc7371ca5c8722c896fd64a258ddd2 (diff) | |
| download | monzero-core-10ad0d7eb274bcbad064eaa0de0483d6f94231d3.tar.gz monzero-core-10ad0d7eb274bcbad064eaa0de0483d6f94231d3.tar.xz monzero-core-10ad0d7eb274bcbad064eaa0de0483d6f94231d3.zip | |
Merge pull request #6718
85efc88c1 Fix overflow issue in epee:misc_utils::rolling_median_t and median(), with unit test (koe)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit_tests/rolling_median.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unit_tests/rolling_median.cpp b/tests/unit_tests/rolling_median.cpp index 730f1e7c5..d415c5b95 100644 --- a/tests/unit_tests/rolling_median.cpp +++ b/tests/unit_tests/rolling_median.cpp @@ -170,6 +170,17 @@ TEST(rolling_median, history_blind) } } +TEST(rolling_median, overflow) +{ + epee::misc_utils::rolling_median_t<uint64_t> m(2); + + uint64_t over_half = static_cast<uint64_t>(3) << static_cast<uint64_t>(62); + m.insert(over_half); + m.insert(over_half); + ASSERT_EQ((over_half + over_half) < over_half, true); + ASSERT_EQ(over_half, m.median()); +} + TEST(rolling_median, size) { epee::misc_utils::rolling_median_t<uint64_t> m(10); |
