12 #define BOOST_TEST_DYN_LINK
13 #define BOOST_TEST_MODULE example_test
15 #include <hipipe/core.hpp>
17 #include <boost/test/unit_test.hpp>
18 #include <range/v3/view/zip.hpp>
25 BOOST_AUTO_TEST_CASE(test_example)
27 namespace hps = hipipe::stream;
28 using hps::from;
using hps::to;
using hps::by;
using hps::dim;
33 std::vector<std::string> logins = {
"marry",
"ted",
"anna",
"josh"};
34 std::vector<int> ages = { 24, 41, 16, 59};
36 auto stream = ranges::views::zip(logins, ages)
38 | hps::create<login, age>(2)
42 |
hps::transform(from<login>, to<login>, [](
char c) {
return c + 1; }, dim<2>)
44 |
hps::transform(from<login, age>, to<age>, [](std::string l,
int a) {
45 return a + l.length();
48 |
hps::transform(from<login>, to<login>, 0.5, [](std::string) -> std::string {
58 |
hps::filter(from<login, age>, by<age>, [](
int a) {
return a > 30; })
64 std::vector<int> desired = {45, 64};
65 BOOST_TEST(ages == desired, boost::test_tools::per_element());
66 assert((ages == std::vector<int>{45, 64}));