mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-17 22:32:15 +02:00
Added test for #176
This commit is contained in:
@ -237,6 +237,7 @@ project
|
|||||||
[ run sequence/ref_vector.cpp ]
|
[ run sequence/ref_vector.cpp ]
|
||||||
[ run sequence/flatten_view.cpp ]
|
[ run sequence/flatten_view.cpp ]
|
||||||
[ compile sequence/github-159.cpp ]
|
[ compile sequence/github-159.cpp ]
|
||||||
|
[ run sequence/github-176.cpp ]
|
||||||
|
|
||||||
[ compile sequence/size.cpp ]
|
[ compile sequence/size.cpp ]
|
||||||
|
|
||||||
|
50
test/sequence/github-176.cpp
Normal file
50
test/sequence/github-176.cpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2018 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)
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||||
|
#include <boost/fusion/container/vector.hpp>
|
||||||
|
#include <boost/fusion/container/list.hpp>
|
||||||
|
#include <boost/fusion/container/deque.hpp>
|
||||||
|
#include <boost/fusion/tuple/tuple.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
template <typename Sequence>
|
||||||
|
void test_at()
|
||||||
|
{
|
||||||
|
Sequence seq;
|
||||||
|
|
||||||
|
// zero initialized
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 0);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 0);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 0);
|
||||||
|
|
||||||
|
int (&arr)[3] = boost::fusion::deref(boost::fusion::begin(seq));
|
||||||
|
|
||||||
|
arr[0] = 2;
|
||||||
|
arr[1] = 4;
|
||||||
|
arr[2] = 6;
|
||||||
|
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 2);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 4);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 6);
|
||||||
|
|
||||||
|
boost::fusion::at_c<0>(seq)[1] = 42;
|
||||||
|
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(seq)[0] == 2);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(seq)[1] == 42);
|
||||||
|
BOOST_TEST(boost::fusion::at_c<0>(seq)[2] == 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using namespace boost::fusion;
|
||||||
|
|
||||||
|
test_at<vector<int[3]> >();
|
||||||
|
test_at<deque<int[3]> >();
|
||||||
|
test_at<list<int[3]> >();
|
||||||
|
test_at<tuple<int[3]> >();
|
||||||
|
}
|
Reference in New Issue
Block a user