2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-14 12:52:10 +00:00
Files
hana/test/adapted/std_list/functor.cpp
2014-06-20 15:02:50 -04:00

31 lines
938 B
C++

/*
@copyright Louis Dionne 2014
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/adapted/std_list.hpp>
#include <boost/hana/detail/constexpr.hpp>
#include <boost/hana/detail/laws.hpp>
#include <cassert>
#include <list>
using namespace boost::hana;
BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto x) { return x + 1; };
BOOST_HANA_CONSTEXPR_LAMBDA auto g = [](auto x) { return x * 3; };
int main() {
using std_list = std::list<int>;
assert(fmap(f, std_list{}) == std_list{});
assert(fmap(f, std_list{1}) == std_list{2});
assert(fmap(f, std_list{1, 2}) == (std_list{2, 3}));
assert(fmap(f, std_list{1, 2, 3}) == (std_list{2, 3, 4}));
assert(detail::laws<Functor>(std_list{}, f, g));
assert(detail::laws<Functor>(std_list{1}, f, g));
assert(detail::laws<Functor>(std_list{1, 2, 3}, f, g));
}