tests: replace Boost.MPL with Mp11
Change-Id: I2e8410f4acb7f25b5cb9d7846f05163414095cc7
diff --git a/tests/daemon/face/datagram-transport.t.cpp b/tests/daemon/face/datagram-transport.t.cpp
index d86f669..f56e32a 100644
--- a/tests/daemon/face/datagram-transport.t.cpp
+++ b/tests/daemon/face/datagram-transport.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,7 +26,7 @@
#include "unicast-udp-transport-fixture.hpp"
#include "multicast-udp-transport-fixture.hpp"
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
@@ -35,7 +35,7 @@
BOOST_AUTO_TEST_SUITE(Face)
BOOST_AUTO_TEST_SUITE(TestDatagramTransport)
-using DatagramTransportFixtures = boost::mpl::vector<
+using DatagramTransportFixtures = boost::mp11::mp_list<
GENERATE_IP_TRANSPORT_FIXTURE_INSTANTIATIONS(UnicastUdpTransportFixture),
IpTransportFixture<MulticastUdpTransportFixture, AddressFamily::V4, AddressScope::Global, MulticastInterface::Yes>,
IpTransportFixture<MulticastUdpTransportFixture, AddressFamily::V6, AddressScope::LinkLocal, MulticastInterface::Yes>,
diff --git a/tests/daemon/face/multicast-udp-transport.t.cpp b/tests/daemon/face/multicast-udp-transport.t.cpp
index 2457e6d..2080335 100644
--- a/tests/daemon/face/multicast-udp-transport.t.cpp
+++ b/tests/daemon/face/multicast-udp-transport.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,7 +25,7 @@
#include "multicast-udp-transport-fixture.hpp"
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
@@ -34,7 +34,7 @@
BOOST_AUTO_TEST_SUITE(Face)
BOOST_AUTO_TEST_SUITE(TestMulticastUdpTransport)
-using MulticastUdpTransportFixtures = boost::mpl::vector<
+using MulticastUdpTransportFixtures = boost::mp11::mp_list<
IpTransportFixture<MulticastUdpTransportFixture, AddressFamily::V4, AddressScope::Global, MulticastInterface::Yes>,
IpTransportFixture<MulticastUdpTransportFixture, AddressFamily::V6, AddressScope::LinkLocal, MulticastInterface::Yes>,
IpTransportFixture<MulticastUdpTransportFixture, AddressFamily::V6, AddressScope::Global, MulticastInterface::Yes>
diff --git a/tests/daemon/face/stream-transport.t.cpp b/tests/daemon/face/stream-transport.t.cpp
index c827900..90e7b65 100644
--- a/tests/daemon/face/stream-transport.t.cpp
+++ b/tests/daemon/face/stream-transport.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,7 +27,7 @@
#include "unix-stream-transport-fixture.hpp"
#include <boost/asio/read.hpp>
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
@@ -36,7 +36,7 @@
BOOST_AUTO_TEST_SUITE(Face)
BOOST_AUTO_TEST_SUITE(TestStreamTransport)
-using StreamTransportFixtures = boost::mpl::vector<
+using StreamTransportFixtures = boost::mp11::mp_list<
GENERATE_IP_TRANSPORT_FIXTURE_INSTANTIATIONS(TcpTransportFixture),
UnixStreamTransportFixture
>;
diff --git a/tests/daemon/face/tcp-channel.t.cpp b/tests/daemon/face/tcp-channel.t.cpp
index 8937f5b..c7c142f 100644
--- a/tests/daemon/face/tcp-channel.t.cpp
+++ b/tests/daemon/face/tcp-channel.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,16 +27,14 @@
#include "test-ip.hpp"
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
BOOST_AUTO_TEST_SUITE(Face)
BOOST_FIXTURE_TEST_SUITE(TestTcpChannel, TcpChannelFixture)
-using AddressFamilies = boost::mpl::vector<
- std::integral_constant<AddressFamily, AddressFamily::V4>,
- std::integral_constant<AddressFamily, AddressFamily::V6>>;
+using AddressFamilies = boost::mp11::mp_list_c<AddressFamily, AddressFamily::V4, AddressFamily::V6>;
BOOST_AUTO_TEST_CASE_TEMPLATE(ConnectTimeout, F, AddressFamilies)
{
diff --git a/tests/daemon/face/tcp-transport.t.cpp b/tests/daemon/face/tcp-transport.t.cpp
index 9e52dfd..1f1929c 100644
--- a/tests/daemon/face/tcp-transport.t.cpp
+++ b/tests/daemon/face/tcp-transport.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,7 +25,7 @@
#include "tcp-transport-fixture.hpp"
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
@@ -34,7 +34,7 @@
BOOST_AUTO_TEST_SUITE(Face)
BOOST_FIXTURE_TEST_SUITE(TestTcpTransport, IpTransportFixture<TcpTransportFixture>)
-using TcpTransportFixtures = boost::mpl::vector<
+using TcpTransportFixtures = boost::mp11::mp_list<
GENERATE_IP_TRANSPORT_FIXTURE_INSTANTIATIONS(TcpTransportFixture)
>;
diff --git a/tests/daemon/face/tcp-udp-channel.t.cpp b/tests/daemon/face/tcp-udp-channel.t.cpp
index cd57b80..851426e 100644
--- a/tests/daemon/face/tcp-udp-channel.t.cpp
+++ b/tests/daemon/face/tcp-udp-channel.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,7 +28,7 @@
#include "test-ip.hpp"
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
@@ -43,7 +43,7 @@
using Address = IpAddressTypeFromFamily<AF>;
};
-using FixtureAndAddressList = boost::mpl::vector<
+using FixtureAndAddressList = boost::mp11::mp_list<
FixtureAndAddress<TcpChannelFixture, AddressFamily::V4>,
FixtureAndAddress<TcpChannelFixture, AddressFamily::V6>,
FixtureAndAddress<UdpChannelFixture, AddressFamily::V4>,
diff --git a/tests/daemon/face/transport.t.cpp b/tests/daemon/face/transport.t.cpp
index d405e68..800dde9 100644
--- a/tests/daemon/face/transport.t.cpp
+++ b/tests/daemon/face/transport.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -31,18 +31,14 @@
#include "tests/daemon/face/dummy-link-service.hpp"
#include "tests/daemon/face/dummy-transport.hpp"
-#include <boost/mpl/fold.hpp>
-#include <boost/mpl/int.hpp>
-#include <boost/mpl/lambda.hpp>
-#include <boost/mpl/map.hpp>
-#include <boost/mpl/pair.hpp>
-#include <boost/mpl/push_back.hpp>
-#include <boost/mpl/set.hpp>
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/algorithm.hpp>
+#include <boost/mp11/bind.hpp>
+#include <boost/mp11/map.hpp>
+#include <boost/mp11/set.hpp>
namespace nfd::tests {
-namespace mpl = boost::mpl;
+using namespace boost::mp11;
using namespace nfd::face;
BOOST_AUTO_TEST_SUITE(Face)
@@ -68,90 +64,49 @@
BOOST_CHECK_EQUAL(transport->persistencyHistory.back(), ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
}
-/** \brief A macro to declare a TransportState as a integral constant.
- * \note we cannot use mpl::integral_c because TransportState is not an integral type
- */
-#define TRANSPORT_STATE_C(X) mpl::int_<static_cast<int>(TransportState::X)>
+// Map from every TransportState to a valid state transition sequence
+// for entering this state from UP.
+using StateInitSequence = mp_list<
+ mp_list_c<TransportState, TransportState::UP /* nothing to do, state is already UP */>,
+ mp_list_c<TransportState, TransportState::DOWN, TransportState::DOWN>,
+ mp_list_c<TransportState, TransportState::CLOSING, TransportState::CLOSING>,
+ mp_list_c<TransportState, TransportState::FAILED, TransportState::FAILED>,
+ mp_list_c<TransportState, TransportState::CLOSED, TransportState::CLOSING, TransportState::CLOSED>
+>;
+static_assert(mp_is_map<StateInitSequence>());
-/** \brief A map from every TransportState to a valid state transition sequence
- * for entering this state from UP.
- */
-typedef mpl::map<
- mpl::pair<TRANSPORT_STATE_C(UP),
- mpl::vector<>>,
- mpl::pair<TRANSPORT_STATE_C(DOWN),
- mpl::vector<
- TRANSPORT_STATE_C(DOWN)
- >>,
- mpl::pair<TRANSPORT_STATE_C(CLOSING),
- mpl::vector<
- TRANSPORT_STATE_C(CLOSING)
- >>,
- mpl::pair<TRANSPORT_STATE_C(FAILED),
- mpl::vector<
- TRANSPORT_STATE_C(FAILED)
- >>,
- mpl::pair<TRANSPORT_STATE_C(CLOSED),
- mpl::vector<
- TRANSPORT_STATE_C(CLOSING),
- TRANSPORT_STATE_C(CLOSED)
- >>
-> StateEntering;
+using TransportStates = mp_map_keys<StateInitSequence>;
-/** \brief A sequence of all valid TransportStates.
- */
-typedef mpl::fold<StateEntering,
- mpl::vector<>,
- mpl::push_back<mpl::_1, mpl::first<mpl::_2>>
->::type States;
+// The set of all state transitions (cartesian product of TransportStates)
+using AllStateTransitions = mp_product<mp_list, TransportStates, TransportStates>;
-/** \brief A set of all valid state transitions.
- */
-typedef mpl::set<
- mpl::pair<TRANSPORT_STATE_C(UP), TRANSPORT_STATE_C(DOWN)>,
- mpl::pair<TRANSPORT_STATE_C(DOWN), TRANSPORT_STATE_C(UP)>,
- mpl::pair<TRANSPORT_STATE_C(UP), TRANSPORT_STATE_C(CLOSING)>,
- mpl::pair<TRANSPORT_STATE_C(UP), TRANSPORT_STATE_C(FAILED)>,
- mpl::pair<TRANSPORT_STATE_C(DOWN), TRANSPORT_STATE_C(CLOSING)>,
- mpl::pair<TRANSPORT_STATE_C(DOWN), TRANSPORT_STATE_C(FAILED)>,
- mpl::pair<TRANSPORT_STATE_C(CLOSING), TRANSPORT_STATE_C(CLOSED)>,
- mpl::pair<TRANSPORT_STATE_C(FAILED), TRANSPORT_STATE_C(CLOSED)>
-> ValidStateTransitions;
-
-/** \brief A metafunction to generate a sequence of all state transitions
- * from a specified state.
- */
-template<typename FromState, typename Result>
-struct StateTransitionsFrom : mpl::fold<
- States,
- Result,
- mpl::push_back<mpl::_1, mpl::pair<FromState, mpl::_2>>>
-{
-};
-
-/** \brief A sequence of all state transitions.
- */
-typedef mpl::fold<
- States,
- mpl::vector<>,
- mpl::lambda<StateTransitionsFrom<mpl::_2, mpl::_1>>
->::type AllStateTransitions;
-
-#undef TRANSPORT_STATE_C
+// The set of *valid* state transitions
+using ValidStateTransitions = mp_list<
+ mp_list_c<TransportState, TransportState::UP, TransportState::DOWN>,
+ mp_list_c<TransportState, TransportState::UP, TransportState::CLOSING>,
+ mp_list_c<TransportState, TransportState::UP, TransportState::FAILED>,
+ mp_list_c<TransportState, TransportState::DOWN, TransportState::UP>,
+ mp_list_c<TransportState, TransportState::DOWN, TransportState::CLOSING>,
+ mp_list_c<TransportState, TransportState::DOWN, TransportState::FAILED>,
+ mp_list_c<TransportState, TransportState::CLOSING, TransportState::CLOSED>,
+ mp_list_c<TransportState, TransportState::FAILED, TransportState::CLOSED>
+>;
+// Sanity check that there are no duplicates
+static_assert(mp_is_set<ValidStateTransitions>());
+// Sanity check that ValidStateTransitions is a proper subset of AllStateTransitions
+static_assert(mp_all_of_q<ValidStateTransitions, mp_bind_front<mp_set_contains, AllStateTransitions>>());
+static_assert(mp_size<ValidStateTransitions>() < mp_size<AllStateTransitions>());
BOOST_AUTO_TEST_CASE_TEMPLATE(SetState, T, AllStateTransitions)
{
- auto transport = make_unique<DummyTransport>();
-
- auto from = static_cast<TransportState>(T::first::value);
- auto to = static_cast<TransportState>(T::second::value);
+ constexpr TransportState from = mp_first<T>::value;
+ constexpr TransportState to = mp_second<T>::value;
BOOST_TEST_INFO_SCOPE(from << " -> " << to);
- // enter from state
- using Steps = typename mpl::at<StateEntering, mpl::int_<T::first::value>>::type;
- mpl::for_each<Steps>([&transport] (int state) {
- transport->setState(static_cast<TransportState>(state));
- });
+ auto transport = make_unique<DummyTransport>();
+ // initialize transport to the 'from' state
+ using Steps = mp_rest<mp_map_find<StateInitSequence, mp_first<T>>>;
+ mp_for_each<Steps>([&transport] (auto state) { transport->setState(state); });
BOOST_REQUIRE_EQUAL(transport->getState(), from);
bool hasSignal = false;
@@ -162,11 +117,8 @@
});
// do transition
- bool isValid = from == to ||
- mpl::has_key<ValidStateTransitions,
- mpl::pair<mpl::int_<T::first::value>, mpl::int_<T::second::value>>
- >::value;
- if (isValid) {
+ constexpr bool isValid = (from == to) || mp_set_contains<ValidStateTransitions, T>();
+ if constexpr (isValid) {
BOOST_REQUIRE_NO_THROW(transport->setState(to));
BOOST_CHECK_EQUAL(hasSignal, from != to);
}
diff --git a/tests/daemon/face/udp-channel.t.cpp b/tests/daemon/face/udp-channel.t.cpp
index b95ac78..e16331e 100644
--- a/tests/daemon/face/udp-channel.t.cpp
+++ b/tests/daemon/face/udp-channel.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,16 +27,14 @@
#include "test-ip.hpp"
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
BOOST_AUTO_TEST_SUITE(Face)
BOOST_FIXTURE_TEST_SUITE(TestUdpChannel, UdpChannelFixture)
-using AddressFamilies = boost::mpl::vector<
- std::integral_constant<AddressFamily, AddressFamily::V4>,
- std::integral_constant<AddressFamily, AddressFamily::V6>>;
+using AddressFamilies = boost::mp11::mp_list_c<AddressFamily, AddressFamily::V4, AddressFamily::V6>;
BOOST_AUTO_TEST_CASE_TEMPLATE(DefaultMtu, F, AddressFamilies)
{
diff --git a/tests/daemon/face/unicast-udp-transport.t.cpp b/tests/daemon/face/unicast-udp-transport.t.cpp
index b85747d..144fed5 100644
--- a/tests/daemon/face/unicast-udp-transport.t.cpp
+++ b/tests/daemon/face/unicast-udp-transport.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,8 +25,7 @@
#include "unicast-udp-transport-fixture.hpp"
-#include <boost/mpl/vector.hpp>
-#include <boost/mpl/vector_c.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
@@ -35,7 +34,7 @@
BOOST_AUTO_TEST_SUITE(Face)
BOOST_FIXTURE_TEST_SUITE(TestUnicastUdpTransport, IpTransportFixture<UnicastUdpTransportFixture>)
-using UnicastUdpTransportFixtures = boost::mpl::vector<
+using UnicastUdpTransportFixtures = boost::mp11::mp_list<
GENERATE_IP_TRANSPORT_FIXTURE_INSTANTIATIONS(UnicastUdpTransportFixture)
>;
@@ -105,9 +104,9 @@
using RemoteCloseFixture = IpTransportFixture<UnicastUdpTransportFixture,
AddressFamily::Any, AddressScope::Loopback>;
-using RemoteClosePersistencies = boost::mpl::vector_c<ndn::nfd::FacePersistency,
- ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT>;
+using RemoteClosePersistencies = boost::mp11::mp_list_c<ndn::nfd::FacePersistency,
+ ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT>;
BOOST_FIXTURE_TEST_CASE_TEMPLATE(RemoteClose, Persistency, RemoteClosePersistencies, RemoteCloseFixture)
{
diff --git a/tests/daemon/face/websocket-channel.t.cpp b/tests/daemon/face/websocket-channel.t.cpp
index 15d1a57..402f9c6 100644
--- a/tests/daemon/face/websocket-channel.t.cpp
+++ b/tests/daemon/face/websocket-channel.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,16 +28,14 @@
#include "test-ip.hpp"
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
BOOST_AUTO_TEST_SUITE(Face)
BOOST_FIXTURE_TEST_SUITE(TestWebSocketChannel, WebSocketChannelFixture)
-using AddressFamilies = boost::mpl::vector<
- std::integral_constant<AddressFamily, AddressFamily::V4>,
- std::integral_constant<AddressFamily, AddressFamily::V6>>;
+using AddressFamilies = boost::mp11::mp_list_c<AddressFamily, AddressFamily::V4, AddressFamily::V6>;
BOOST_AUTO_TEST_CASE_TEMPLATE(Uri, F, AddressFamilies)
{
diff --git a/tests/daemon/face/websocket-transport.t.cpp b/tests/daemon/face/websocket-transport.t.cpp
index d28d8a3..225cf80 100644
--- a/tests/daemon/face/websocket-transport.t.cpp
+++ b/tests/daemon/face/websocket-transport.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,7 +25,7 @@
#include "websocket-transport-fixture.hpp"
-#include <boost/mpl/vector.hpp>
+#include <boost/mp11/list.hpp>
namespace nfd::tests {
@@ -34,7 +34,7 @@
BOOST_AUTO_TEST_SUITE(Face)
BOOST_FIXTURE_TEST_SUITE(TestWebSocketTransport, IpTransportFixture<WebSocketTransportFixture>)
-using WebSocketTransportFixtures = boost::mpl::vector<
+using WebSocketTransportFixtures = boost::mp11::mp_list<
GENERATE_IP_TRANSPORT_FIXTURE_INSTANTIATIONS(WebSocketTransportFixture)
>;
@@ -55,7 +55,7 @@
BOOST_CHECK_EQUAL(this->transport->getSendQueueCapacity(), QUEUE_UNSUPPORTED);
}
-using StaticPropertiesV4MappedFixtures = boost::mpl::vector<
+using StaticPropertiesV4MappedFixtures = boost::mp11::mp_list<
IpTransportFixture<WebSocketTransportFixture, AddressFamily::V4, AddressScope::Loopback>,
IpTransportFixture<WebSocketTransportFixture, AddressFamily::V4, AddressScope::Global>
>;