mirror of
https://github.com/boostorg/iterator.git
synced 2025-05-12 14:01:37 +00:00
Add tests for fusion based zip_iterator
Signed-off-by: Kohei Takahashi <flast@flast.jp>
This commit is contained in:
parent
782313db8c
commit
9841d87212
@ -14,11 +14,13 @@ test-suite iterator
|
|||||||
|
|
||||||
[ run zip_iterator_test.cpp
|
[ run zip_iterator_test.cpp
|
||||||
: : :
|
: : :
|
||||||
|
|
||||||
# stlport's debug mode generates long symbols which overwhelm
|
# stlport's debug mode generates long symbols which overwhelm
|
||||||
# vc6
|
# vc6
|
||||||
#<msvc-stlport><*><runtime-build>release
|
#<msvc-stlport><*><runtime-build>release
|
||||||
]
|
]
|
||||||
|
[ run zip_iterator_test_fusion.cpp ]
|
||||||
|
[ run zip_iterator_test_std_tuple.cpp ]
|
||||||
|
[ run zip_iterator_test_std_pair.cpp ]
|
||||||
|
|
||||||
# These tests should work for just about everything.
|
# These tests should work for just about everything.
|
||||||
[ compile is_lvalue_iterator.cpp ]
|
[ compile is_lvalue_iterator.cpp ]
|
||||||
|
73
test/detail/zip_iterator_test.ipp
Normal file
73
test/detail/zip_iterator_test.ipp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// Copyright (c) 2014 Kohei Takahashi.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
#include <boost/assign/list_of.hpp>
|
||||||
|
#include <boost/fusion/include/at.hpp>
|
||||||
|
#include <boost/iterator/zip_iterator.hpp>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
typedef TUPLE<
|
||||||
|
std::vector<int>::iterator,
|
||||||
|
std::vector<std::string>::iterator
|
||||||
|
> iterator_tuple;
|
||||||
|
|
||||||
|
std::vector<int> vi = boost::assign::list_of(42)(72);
|
||||||
|
std::vector<std::string> vs = boost::assign::list_of("kokoro")("pyonpyon");
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::zip_iterator<iterator_tuple> i1(MAKE_TUPLE(vi.begin(), vs.begin()));
|
||||||
|
boost::zip_iterator<iterator_tuple> i2 = i1;
|
||||||
|
|
||||||
|
BOOST_TEST( i1 == i2);
|
||||||
|
BOOST_TEST( i1++ == i2);
|
||||||
|
BOOST_TEST( i1 == (i2 + 1));
|
||||||
|
BOOST_TEST((i1 - 1) == i2);
|
||||||
|
BOOST_TEST( i1-- == ++i2);
|
||||||
|
BOOST_TEST( i1 == --i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::zip_iterator<iterator_tuple> i1(MAKE_TUPLE(vi.begin(), vs.begin()));
|
||||||
|
boost::zip_iterator<iterator_tuple> i2 = i1 + 1;
|
||||||
|
|
||||||
|
BOOST_TEST( i1 != i2);
|
||||||
|
BOOST_TEST( i1++ != i2);
|
||||||
|
BOOST_TEST( i1 != (i2 + 1));
|
||||||
|
BOOST_TEST((i1 - 1) != i2);
|
||||||
|
BOOST_TEST( i1-- != ++i2);
|
||||||
|
BOOST_TEST( i1 != --i2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::zip_iterator<iterator_tuple> i(MAKE_TUPLE(vi.begin(), vs.begin()));
|
||||||
|
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(* i ) == 42);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<1>(* i ) == "kokoro");
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(*(i + 1)) == 72);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<1>(*(i + 1)) == "pyonpyon");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::zip_iterator<iterator_tuple> i1(MAKE_TUPLE(vi.begin(), vs.begin()));
|
||||||
|
boost::zip_iterator<iterator_tuple> i2(MAKE_TUPLE(vi.end(), vs.end()));
|
||||||
|
|
||||||
|
BOOST_TEST((i2 - i1) == 2);
|
||||||
|
++i1;
|
||||||
|
BOOST_TEST((i2 - i1) == 1);
|
||||||
|
--i2;
|
||||||
|
BOOST_TEST((i2 - i1) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
15
test/zip_iterator_test_fusion.cpp
Normal file
15
test/zip_iterator_test_fusion.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (c) 2014 Kohei Takahashi.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
#include <boost/fusion/include/vector.hpp>
|
||||||
|
#include <boost/fusion/include/make_vector.hpp>
|
||||||
|
|
||||||
|
#define TUPLE boost::fusion::vector
|
||||||
|
#define MAKE_TUPLE boost::fusion::make_vector
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test.ipp"
|
16
test/zip_iterator_test_std_pair.cpp
Normal file
16
test/zip_iterator_test_std_pair.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2014 Kohei Takahashi.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <boost/fusion/adapted/std_pair.hpp>
|
||||||
|
|
||||||
|
#define TUPLE std::pair
|
||||||
|
#define MAKE_TUPLE std::make_pair
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test.ipp"
|
||||||
|
|
29
test/zip_iterator_test_std_tuple.cpp
Normal file
29
test/zip_iterator_test_std_tuple.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) 2014 Kohei Takahashi.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||||
|
|
||||||
|
#define TUPLE std::tuple
|
||||||
|
#define MAKE_TUPLE std::make_tuple
|
||||||
|
|
||||||
|
#include "detail/zip_iterator_test.ipp"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user