-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[view] Add tests for modifying the elements of a view
- Loading branch information
Showing
6 changed files
with
195 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright Louis Dionne 2013-2016 | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | ||
|
||
#include <boost/hana/assert.hpp> | ||
#include <boost/hana/at.hpp> | ||
#include <boost/hana/view.hpp> | ||
|
||
#include <support/seq.hpp> | ||
namespace hana = boost::hana; | ||
|
||
|
||
int main() { | ||
auto container = ::seq; | ||
|
||
auto storage = container(container(0, 1, 2), | ||
container(3, 4), | ||
container(), | ||
container(5)); | ||
auto view = hana::detail::flattened(storage); | ||
hana::at_c<0>(view) = 90; | ||
hana::at_c<1>(view) = 91; | ||
hana::at_c<2>(view) = 92; | ||
hana::at_c<3>(view) = 93; | ||
hana::at_c<4>(view) = 94; | ||
hana::at_c<5>(view) = 95; | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(view) == 92); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(view) == 93); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<4>(view) == 94); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<5>(view) == 95); | ||
|
||
auto& storage1 = hana::at_c<0>(storage); | ||
auto& storage2 = hana::at_c<1>(storage); | ||
auto& storage4 = hana::at_c<3>(storage); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage1) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage1) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage1) == 92); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage2) == 93); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage2) == 94); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage4) == 95); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright Louis Dionne 2013-2016 | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | ||
|
||
#include <boost/hana/assert.hpp> | ||
#include <boost/hana/at.hpp> | ||
#include <boost/hana/view.hpp> | ||
|
||
#include <support/seq.hpp> | ||
namespace hana = boost::hana; | ||
|
||
|
||
int main() { | ||
auto container = ::seq; | ||
|
||
auto storage = container(0, 1, 2); | ||
auto view = hana::detail::identity_view(storage); | ||
hana::at_c<0>(view) = 90; | ||
hana::at_c<1>(view) = 91; | ||
hana::at_c<2>(view) = 92; | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(view) == 92); | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage) == 92); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright Louis Dionne 2013-2016 | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | ||
|
||
#include <boost/hana/assert.hpp> | ||
#include <boost/hana/at.hpp> | ||
#include <boost/hana/view.hpp> | ||
|
||
#include <support/seq.hpp> | ||
namespace hana = boost::hana; | ||
|
||
|
||
int main() { | ||
auto container = ::seq; | ||
|
||
auto storage1 = container(0, 1, 2); | ||
auto storage2 = container(3, 4); | ||
auto view = hana::detail::joined(storage1, storage2); | ||
hana::at_c<0>(view) = 90; | ||
hana::at_c<1>(view) = 91; | ||
hana::at_c<2>(view) = 92; | ||
hana::at_c<3>(view) = 93; | ||
hana::at_c<4>(view) = 94; | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(view) == 92); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(view) == 93); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<4>(view) == 94); | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage1) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage1) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage1) == 92); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage2) == 93); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage2) == 94); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Louis Dionne 2013-2016 | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | ||
|
||
#include <boost/hana/assert.hpp> | ||
#include <boost/hana/at.hpp> | ||
#include <boost/hana/view.hpp> | ||
namespace hana = boost::hana; | ||
|
||
|
||
int main() { | ||
auto view = hana::detail::single_view(3); | ||
hana::at_c<0>(view) = 93; | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 93); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright Louis Dionne 2013-2016 | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | ||
|
||
#include <boost/hana/assert.hpp> | ||
#include <boost/hana/at.hpp> | ||
#include <boost/hana/range.hpp> | ||
#include <boost/hana/view.hpp> | ||
|
||
#include <support/seq.hpp> | ||
|
||
#include <cstddef> | ||
namespace hana = boost::hana; | ||
|
||
|
||
int main() { | ||
auto container = ::seq; | ||
|
||
{ | ||
auto storage = container(0, 1, 2); | ||
auto view = hana::detail::sliced(storage, hana::range_c<std::size_t, 0, 3>); | ||
hana::at_c<0>(view) = 90; | ||
hana::at_c<1>(view) = 91; | ||
hana::at_c<2>(view) = 92; | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(view) == 92); | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage) == 92); | ||
} | ||
|
||
{ | ||
auto storage = container(0, 1, 2); | ||
auto view = hana::detail::sliced(storage, hana::range_c<std::size_t, 0, 2>); | ||
hana::at_c<0>(view) = 90; | ||
hana::at_c<1>(view) = 91; | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 91); | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage) == 90); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage) == 02); | ||
} | ||
|
||
{ | ||
auto storage = container(7, 1, 2); | ||
auto view = hana::detail::sliced(storage, hana::range_c<std::size_t, 1, 3>); | ||
hana::at_c<0>(view) = 91; | ||
hana::at_c<1>(view) = 92; | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(view) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(view) == 92); | ||
|
||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(storage) == 07); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(storage) == 91); | ||
BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(storage) == 92); | ||
} | ||
} |