forked from boostorg/mp11
Add mp_repeat test with value lists. Refs #53.
This commit is contained in:
@ -85,6 +85,7 @@ run mp_contains.cpp ;
|
||||
run mp_starts_with.cpp ;
|
||||
run mp_starts_with_sf.cpp ;
|
||||
run mp_repeat.cpp ;
|
||||
run mp_repeat_2.cpp ;
|
||||
run mp_product.cpp ;
|
||||
run mp_drop.cpp ;
|
||||
run mp_iota.cpp ;
|
||||
|
125
test/mp_repeat_2.cpp
Normal file
125
test/mp_repeat_2.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
#include <boost/mp11/list.hpp>
|
||||
#include <boost/mp11/integral.hpp>
|
||||
|
||||
#if !defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
|
||||
|
||||
#pragma message("Test skipped because BOOST_MP11_HAS_TEMPLATE_AUTO is not defined")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
template<auto... A> struct V1 {};
|
||||
template<int... I> struct V2 {};
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::mp11::mp_repeat;
|
||||
using boost::mp11::mp_repeat_c;
|
||||
using boost::mp11::mp_false;
|
||||
using boost::mp11::mp_true;
|
||||
using boost::mp11::mp_int;
|
||||
using boost::mp11::mp_size_t;
|
||||
|
||||
using L1 = V1<>;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L1, 0>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L1, 1>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L1, 2>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L1, 3>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L1, 31>, V1<>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L1, mp_false>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L1, mp_true>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L1, mp_int<2>>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L1, mp_int<3>>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L1, mp_size_t<31>>, V1<>);
|
||||
|
||||
using L2 = V1<true>;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L2, 0>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L2, 1>, V1<true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L2, 2>, V1<true, true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L2, 3>, V1<true, true, true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L2, 4>, V1<true, true, true, true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L2, 5>, V1<true, true, true, true, true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L2, 6>, V1<true, true, true, true, true, true>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L2, mp_false>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L2, mp_true>, V1<true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L2, mp_int<2>>, V1<true, true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L2, mp_int<3>>, V1<true, true, true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L2, mp_int<4>>, V1<true, true, true, true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L2, mp_size_t<5>>, V1<true, true, true, true, true>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L2, mp_size_t<6>>, V1<true, true, true, true, true, true>);
|
||||
|
||||
using L3 = V1<true, 2>;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L3, 0>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L3, 1>, V1<true, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L3, 2>, V1<true, 2, true, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L3, 3>, V1<true, 2, true, 2, true, 2>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L3, mp_false>, V1<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L3, mp_true>, V1<true, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L3, mp_int<2>>, V1<true, 2, true, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L3, mp_size_t<3>>, V1<true, 2, true, 2, true, 2>);
|
||||
|
||||
//
|
||||
|
||||
using L4 = V2<>;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L4, 0>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L4, 1>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L4, 2>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L4, 3>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L4, 31>, V2<>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L4, mp_false>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L4, mp_true>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L4, mp_int<2>>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L4, mp_int<3>>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L4, mp_size_t<31>>, V2<>);
|
||||
|
||||
using L5 = V2<1>;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L5, 0>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L5, 1>, V2<1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L5, 2>, V2<1, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L5, 3>, V2<1, 1, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L5, 4>, V2<1, 1, 1, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L5, 5>, V2<1, 1, 1, 1, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L5, 6>, V2<1, 1, 1, 1, 1, 1>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L5, mp_false>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L5, mp_true>, V2<1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L5, mp_int<2>>, V2<1, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L5, mp_int<3>>, V2<1, 1, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L5, mp_int<4>>, V2<1, 1, 1, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L5, mp_size_t<5>>, V2<1, 1, 1, 1, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L5, mp_size_t<6>>, V2<1, 1, 1, 1, 1, 1>);
|
||||
|
||||
using L6 = V2<1, 2>;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L6, 0>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L6, 1>, V2<1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L6, 2>, V2<1, 2, 1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat_c<L6, 3>, V2<1, 2, 1, 2, 1, 2>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L6, mp_false>, V2<>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L6, mp_true>, V2<1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L6, mp_int<2>>, V2<1, 2, 1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(mp_repeat<L6, mp_size_t<3>>, V2<1, 2, 1, 2, 1, 2>);
|
||||
|
||||
//
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user