From ac65812efd4ee45dca35d78a5d1baff2ca1a5a33 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 16 May 2023 19:21:53 +0300 Subject: [PATCH] Add a test for mp_back with value lists. Refs #53. --- test/Jamfile | 1 + test/mp_back_2.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/mp_back_2.cpp diff --git a/test/Jamfile b/test/Jamfile index 886a31c..665354b 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -143,6 +143,7 @@ run mp_max_element_q.cpp ; run mp_nth_element.cpp ; run mp_nth_element_q.cpp ; run mp_back.cpp ; +run mp_back_2.cpp ; run mp_pop_back.cpp ; run mp_flatten.cpp ; run mp_rotate_left.cpp ; diff --git a/test/mp_back_2.cpp b/test/mp_back_2.cpp new file mode 100644 index 0000000..1d05c94 --- /dev/null +++ b/test/mp_back_2.cpp @@ -0,0 +1,57 @@ +// Copyright 2023 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include + +#if !defined(BOOST_MP11_HAS_TEMPLATE_AUTO) + +#pragma message("Test skipped because BOOST_MP11_HAS_TEMPLATE_AUTO is not defined") +int main() {} + +#else + +#include + +template struct V1 {}; +template struct V2 {}; + +int main() +{ + using boost::mp11::mp_back; + using boost::mp11::mp_false; + using boost::mp11::mp_int; + + using L1 = V1; + BOOST_TEST_TRAIT_SAME(mp_back, mp_false); + + using L2 = V1; + BOOST_TEST_TRAIT_SAME(mp_back, mp_int<4>); + + using L3 = V2<0>; + BOOST_TEST_TRAIT_SAME(mp_back, mp_int<0>); + + using L4 = V2<0, 1, 2, 3, 4, 5, 6, 7, 8, 9>; + BOOST_TEST_TRAIT_SAME(mp_back, mp_int<9>); + + using boost::mp11::mp_iota_c; + using boost::mp11::mp_rename_v; + using boost::mp11::mp_size_t; + + int const N = 137; + + using L6 = mp_rename_v, V1>; + BOOST_TEST_TRAIT_SAME(mp_back, mp_size_t); + + using boost::mp11::mp_valid; + + using L7 = V1<>; + BOOST_TEST_TRAIT_FALSE((mp_valid)); + + return boost::report_errors(); +} + +#endif