Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
Iterator.ut.cpp
Go to the documentation of this file.
1// The Reactive C++ Toolbox.
2// Copyright (C) 2013-2019 Swirly Cloud Limited
3// Copyright (C) 2021 Reactive Markets Limited
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17#include "Utility.hpp"
18
19#include "Histogram.hpp"
20#include "Iterator.hpp"
21
22#include <boost/test/unit_test.hpp>
23
24using namespace std;
25using namespace toolbox;
26
28
30{
31 Histogram h{1, 255, 2};
32 BOOST_CHECK(h.record_value(193));
33 BOOST_CHECK(h.record_value(255));
34 BOOST_CHECK(h.record_value(0));
35 BOOST_CHECK(h.record_value(1));
36 BOOST_CHECK(h.record_value(64));
37 BOOST_CHECK(h.record_value(128));
38
39 int step_count{0};
40 int64_t total_count{0};
41
42 LinearIterator iter{h, 64};
43 while (iter.next()) {
45 if (step_count == 0) {
46 h.record_value(2);
47 }
48 ++step_count;
49 }
50
52 BOOST_CHECK_EQUAL(total_count, 6);
53}
54
BOOST_AUTO_TEST_CASE(IteratorLinearIteratorCase)
BOOST_CHECK_EQUAL(v.size(), 10U)
std::int64_t count_added_in_this_iteration_step() const noexcept
Definition Iterator.hpp:123
A High Dynamic Range (HDR) Histogram.
Definition Histogram.hpp:64
LinearIterator is a linear value iterator.
Definition Iterator.hpp:154
STL namespace.
constexpr auto bind() noexcept
Definition Slot.hpp:92
BOOST_CHECK(isnan(stod(""sv, numeric_limits< double >::quiet_NaN())))