29 #define BOOST_TEST_MODULE ( NestedIterator_test ) 30 #include "boost/test/unit_test.hpp" 55 using DoubleVectorI_t = std::vector<std::vector<int>>;
56 DoubleVectorI_t
data(1);
57 constexpr
size_t NElements = 10000;
58 constexpr
float SwitchProbability = 0.1;
60 static std::default_random_engine random_engine(
RandomSeed);
61 std::uniform_real_distribution<float> uniform(0., 1.);
63 unsigned int nEmpty = 0;
64 for (
size_t i = 0; i < NElements; ++i) {
66 if (uniform(random_engine) < SwitchProbability) {
67 if (data.back().empty()) ++nEmpty;
71 data.back().push_back(i);
73 std::cout <<
"Working with " << NElements <<
" elements in " << data.size()
74 <<
" vectors (" << nEmpty <<
" empty) in a vector" <<
std::endl;
76 unsigned int nMismatches = 0;
82 while (iElem != eend) {
84 if (elem != expected) ++nMismatches;
89 BOOST_TEST((
unsigned int) expected == NElements);
90 BOOST_TEST(nMismatches == 0U);
105 using VectorMapI_t = std::map<int, std::vector<int>>;
109 constexpr
size_t NElements = 10000;
110 constexpr
float SwitchProbability = 0.1;
112 static std::default_random_engine random_engine(
RandomSeed);
113 std::uniform_real_distribution<float> uniform(0., 1.);
115 unsigned int nEmpty = 0;
116 for (
size_t i = 0; i < NElements; ++i) {
118 if (uniform(random_engine) < SwitchProbability) {
119 if (data.rbegin()->second.empty()) ++nEmpty;
120 data.insert({ data.size(), {} });
123 data.rbegin()->second.push_back(i);
125 std::cout <<
"Working with " << NElements <<
" elements in " << data.size()
126 <<
" vectors (" << nEmpty <<
" empty) in a map" <<
std::endl;
128 unsigned int nMismatches = 0;
135 while (iElem != eend) {
137 if (elem != expected) ++nMismatches;
142 BOOST_TEST((
unsigned int) expected == NElements);
143 BOOST_TEST(nMismatches == 0U);
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
BOOST_AUTO_TEST_CASE(RunVectorVector)
constexpr unsigned int RandomSeed
The seed for the default random engine.
void RunVectorVectorTest()
Tests bulk allocator with a vector of vectors.
Internal helper class: actual implementation of nested iterator.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Iterators recursing though nested collections.
QTextStream & endl(QTextStream &s)
void RunVectorMapTest()
Tests bulk allocator with a map of vectors.