14 #define BOOST_TEST_MODULE ( CollectionView_test ) 15 #include <boost/test/unit_test.hpp> 20 #include <forward_list> 31 std::vector<int>
c{ 3, 4, 5 };
33 auto const cend =
c.cend();
37 BOOST_TEST(cv.empty() ==
c.empty());
38 BOOST_TEST(cv.size() ==
c.size());
43 BOOST_TEST((cv.cbegin() ==
c.cbegin()));
44 BOOST_TEST((cv.cend() ==
c.cend()));
45 BOOST_TEST((cv.crbegin() ==
c.crbegin()));
46 BOOST_TEST((cv.crend() ==
c.crend()));
51 BOOST_TEST(&(cv.front()) == &(
c.front()));
52 BOOST_TEST(cv.front() ==
c.front());
53 BOOST_TEST(&(cv.back()) == &(
c.back()));
54 BOOST_TEST(cv.back() ==
c.back());
59 BOOST_TEST(cv.data() ==
c.data());
66 for (
auto const&
d: cv) {
68 BOOST_TEST(cv[i] ==
d);
69 BOOST_TEST(&(cv[i]) == &(
c[i]));
70 BOOST_TEST(cv.at(i) ==
d);
71 BOOST_TEST(&(cv.at(i)) == &(
c.at(i)));
76 BOOST_TEST((ic ==
cend));
86 std::deque<int>
c{ 3, 4, 5 };
88 auto const cend =
c.cend();
92 BOOST_TEST(cv.empty() ==
c.empty());
93 BOOST_TEST(cv.size() ==
c.size());
98 BOOST_TEST((cv.cbegin() ==
c.cbegin()));
99 BOOST_TEST((cv.cend() ==
c.cend()));
100 BOOST_TEST((cv.crbegin() ==
c.crbegin()));
101 BOOST_TEST((cv.crend() ==
c.crend()));
106 BOOST_TEST(&(cv.front()) == &(
c.front()));
107 BOOST_TEST(cv.front() ==
c.front());
108 BOOST_TEST(&(cv.back()) == &(
c.back()));
109 BOOST_TEST(cv.back() ==
c.back());
116 for (
auto const&
d: cv) {
117 BOOST_TEST(
d == *ic);
118 BOOST_TEST(cv[i] ==
d);
119 BOOST_TEST(&(cv[i]) == &(
c[i]));
120 BOOST_TEST(cv.at(i) ==
d);
121 BOOST_TEST(&(cv.at(i)) == &(
c.at(i)));
126 BOOST_TEST((ic ==
cend));
136 std::list<int>
c{ 3, 4, 5 };
137 auto const cbegin =
c.cbegin();
138 auto const cend =
c.cend();
142 BOOST_TEST(cv.empty() ==
c.empty());
143 BOOST_TEST(cv.size() ==
c.size());
148 BOOST_TEST((cv.cbegin() ==
c.cbegin()));
149 BOOST_TEST((cv.cend() ==
c.cend()));
150 BOOST_TEST((cv.crbegin() ==
c.crbegin()));
151 BOOST_TEST((cv.crend() ==
c.crend()));
156 BOOST_TEST(&(cv.front()) == &(
c.front()));
157 BOOST_TEST(cv.front() ==
c.front());
158 BOOST_TEST(&(cv.back()) == &(
c.back()));
159 BOOST_TEST(cv.back() ==
c.back());
165 for (
auto const&
d: cv) {
166 BOOST_TEST(
d == *ic);
170 BOOST_TEST((ic ==
cend));
180 std::forward_list<int>
c{ 3, 4, 5 };
181 auto const cbegin =
c.cbegin();
182 auto const cend =
c.cend();
186 BOOST_TEST(cv.empty() ==
c.empty());
191 BOOST_TEST((cv.cbegin() ==
c.cbegin()));
192 BOOST_TEST((cv.cend() ==
c.cend()));
197 BOOST_TEST(&(cv.front()) == &(
c.front()));
198 BOOST_TEST(cv.front() ==
c.front());
204 for (
auto const&
d: cv) {
205 BOOST_TEST(
d == *ic);
209 BOOST_TEST((ic ==
cend));
217 std::ostringstream out;
234 std::vector<int> range(5);
235 std::iota(range.begin(), range.end(), 1);
242 BOOST_TEST(out.str() ==
"1 2 3 4 5 ");
257 BOOST_TEST(out.str() ==
"1 2 3 4 5 ");
273 BOOST_TEST(out.str() ==
"1 2 3 4 5 ");
289 std::vector<int> v(10);
290 std::iota(v.begin(), v.end(), 0);
297 BOOST_TEST(out.str() ==
"4 5 6 ");
323 std::vector<int> v_data(10);
324 std::iota(v_data.begin(), v_data.end(), 0);
327 using vector_t = std::vector<int>;
334 auto begin()
const -> decltype(
auto) {
return data.cbegin(); }
335 auto end()
const -> decltype(
auto) {
return data.cend(); }
341 struct MyCollection:
public IntViewBase_t {
352 BOOST_TEST(out.str() ==
"0 1 2 3 4 5 6 7 8 9 ");
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Provides features of a collections, from begin and end iterators.
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Provides the features of a collections, from begin and end iterators.
auto makeCollectionView(BeginIter const &b, EndIter const &e)
Creates a CollectionView from the specified iterators.
std::vector< int > IntVector
BOOST_AUTO_TEST_CASE(VectorTestCase)
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
CollectionView< Range > const & wrapCollectionIntoView(Range const &c)
Returns the specified container, wrapped in the view.
QTextStream & endl(QTextStream &s)