diff --git a/tests/daemon/face/datagram-transport.t.cpp b/tests/daemon/face/datagram-transport.t.cpp index d86f669f..f56e32ab 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 +#include namespace nfd::tests { @@ -35,7 +35,7 @@ using namespace nfd::face; 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, IpTransportFixture, diff --git a/tests/daemon/face/multicast-udp-transport.t.cpp b/tests/daemon/face/multicast-udp-transport.t.cpp index 2457e6d6..2080335d 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 +#include namespace nfd::tests { @@ -34,7 +34,7 @@ using namespace nfd::face; BOOST_AUTO_TEST_SUITE(Face) BOOST_AUTO_TEST_SUITE(TestMulticastUdpTransport) -using MulticastUdpTransportFixtures = boost::mpl::vector< +using MulticastUdpTransportFixtures = boost::mp11::mp_list< IpTransportFixture, IpTransportFixture, IpTransportFixture diff --git a/tests/daemon/face/stream-transport.t.cpp b/tests/daemon/face/stream-transport.t.cpp index c827900f..90e7b657 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 -#include +#include namespace nfd::tests { @@ -36,7 +36,7 @@ using namespace nfd::face; 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 8937f5bd..c7c142fc 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 +#include namespace nfd::tests { BOOST_AUTO_TEST_SUITE(Face) BOOST_FIXTURE_TEST_SUITE(TestTcpChannel, TcpChannelFixture) -using AddressFamilies = boost::mpl::vector< - std::integral_constant, - std::integral_constant>; +using AddressFamilies = boost::mp11::mp_list_c; 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 9e52dfd4..1f1929cb 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 +#include namespace nfd::tests { @@ -34,7 +34,7 @@ using namespace nfd::face; BOOST_AUTO_TEST_SUITE(Face) BOOST_FIXTURE_TEST_SUITE(TestTcpTransport, IpTransportFixture) -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 cd57b80c..851426eb 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 +#include namespace nfd::tests { @@ -43,7 +43,7 @@ struct FixtureAndAddress using Address = IpAddressTypeFromFamily; }; -using FixtureAndAddressList = boost::mpl::vector< +using FixtureAndAddressList = boost::mp11::mp_list< FixtureAndAddress, FixtureAndAddress, FixtureAndAddress, diff --git a/tests/daemon/face/transport.t.cpp b/tests/daemon/face/transport.t.cpp index d405e682..800dde9c 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 -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include 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_AUTO_TEST_CASE(PersistencyChange) 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_(TransportState::X)> - -/** \brief A map from every TransportState to a valid state transition sequence - * for entering this state from UP. - */ -typedef mpl::map< - mpl::pair>, - mpl::pair>, - mpl::pair>, - mpl::pair>, - mpl::pair> -> StateEntering; - -/** \brief A sequence of all valid TransportStates. - */ -typedef mpl::fold, - mpl::push_back> ->::type States; - -/** \brief A set of all valid state transitions. - */ -typedef mpl::set< - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair -> ValidStateTransitions; - -/** \brief A metafunction to generate a sequence of all state transitions - * from a specified state. - */ -template -struct StateTransitionsFrom : mpl::fold< - States, - Result, - mpl::push_back>> -{ -}; - -/** \brief A sequence of all state transitions. - */ -typedef mpl::fold< - States, - mpl::vector<>, - mpl::lambda> ->::type AllStateTransitions; - -#undef TRANSPORT_STATE_C +// Map from every TransportState to a valid state transition sequence +// for entering this state from UP. +using StateInitSequence = mp_list< + mp_list_c, + mp_list_c, + mp_list_c, + mp_list_c, + mp_list_c +>; +static_assert(mp_is_map()); + +using TransportStates = mp_map_keys; + +// The set of all state transitions (cartesian product of TransportStates) +using AllStateTransitions = mp_product; + +// The set of *valid* state transitions +using ValidStateTransitions = mp_list< + mp_list_c, + mp_list_c, + mp_list_c, + mp_list_c, + mp_list_c, + mp_list_c, + mp_list_c, + mp_list_c +>; +// Sanity check that there are no duplicates +static_assert(mp_is_set()); +// Sanity check that ValidStateTransitions is a proper subset of AllStateTransitions +static_assert(mp_all_of_q>()); +static_assert(mp_size() < mp_size()); BOOST_AUTO_TEST_CASE_TEMPLATE(SetState, T, AllStateTransitions) { - auto transport = make_unique(); - - auto from = static_cast(T::first::value); - auto to = static_cast(T::second::value); + constexpr TransportState from = mp_first::value; + constexpr TransportState to = mp_second::value; BOOST_TEST_INFO_SCOPE(from << " -> " << to); - // enter from state - using Steps = typename mpl::at>::type; - mpl::for_each([&transport] (int state) { - transport->setState(static_cast(state)); - }); + auto transport = make_unique(); + // initialize transport to the 'from' state + using Steps = mp_rest>>; + mp_for_each([&transport] (auto state) { transport->setState(state); }); BOOST_REQUIRE_EQUAL(transport->getState(), from); bool hasSignal = false; @@ -162,11 +117,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SetState, T, AllStateTransitions) }); // do transition - bool isValid = from == to || - mpl::has_key, mpl::int_> - >::value; - if (isValid) { + constexpr bool isValid = (from == to) || mp_set_contains(); + 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 b95ac783..e16331e2 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 +#include namespace nfd::tests { BOOST_AUTO_TEST_SUITE(Face) BOOST_FIXTURE_TEST_SUITE(TestUdpChannel, UdpChannelFixture) -using AddressFamilies = boost::mpl::vector< - std::integral_constant, - std::integral_constant>; +using AddressFamilies = boost::mp11::mp_list_c; 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 b85747da..144fed59 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 -#include +#include namespace nfd::tests { @@ -35,7 +34,7 @@ using namespace nfd::face; BOOST_AUTO_TEST_SUITE(Face) BOOST_FIXTURE_TEST_SUITE(TestUnicastUdpTransport, IpTransportFixture) -using UnicastUdpTransportFixtures = boost::mpl::vector< +using UnicastUdpTransportFixtures = boost::mp11::mp_list< GENERATE_IP_TRANSPORT_FIXTURE_INSTANTIATIONS(UnicastUdpTransportFixture) >; @@ -105,9 +104,9 @@ BOOST_AUTO_TEST_CASE(IdleClose) using RemoteCloseFixture = IpTransportFixture; -using RemoteClosePersistencies = boost::mpl::vector_c; +using RemoteClosePersistencies = boost::mp11::mp_list_c; 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 15d1a572..402f9c68 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 +#include namespace nfd::tests { BOOST_AUTO_TEST_SUITE(Face) BOOST_FIXTURE_TEST_SUITE(TestWebSocketChannel, WebSocketChannelFixture) -using AddressFamilies = boost::mpl::vector< - std::integral_constant, - std::integral_constant>; +using AddressFamilies = boost::mp11::mp_list_c; 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 d28d8a30..225cf80b 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 +#include namespace nfd::tests { @@ -34,7 +34,7 @@ using namespace nfd::face; BOOST_AUTO_TEST_SUITE(Face) BOOST_FIXTURE_TEST_SUITE(TestWebSocketTransport, IpTransportFixture) -using WebSocketTransportFixtures = boost::mpl::vector< +using WebSocketTransportFixtures = boost::mp11::mp_list< GENERATE_IP_TRANSPORT_FIXTURE_INSTANTIATIONS(WebSocketTransportFixture) >; @@ -55,7 +55,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(StaticProperties, T, WebSocketTransportFixtures BOOST_CHECK_EQUAL(this->transport->getSendQueueCapacity(), QUEUE_UNSUPPORTED); } -using StaticPropertiesV4MappedFixtures = boost::mpl::vector< +using StaticPropertiesV4MappedFixtures = boost::mp11::mp_list< IpTransportFixture, IpTransportFixture >; diff --git a/tests/daemon/fw/multicast-strategy.t.cpp b/tests/daemon/fw/multicast-strategy.t.cpp index aa18cdf1..55254daf 100644 --- a/tests/daemon/fw/multicast-strategy.t.cpp +++ b/tests/daemon/fw/multicast-strategy.t.cpp @@ -32,6 +32,8 @@ #include "strategy-tester.hpp" #include "topology-tester.hpp" +#include + namespace nfd::tests { using MulticastStrategyTester = StrategyTester; @@ -470,7 +472,7 @@ class InFaceSelection2 : public ForwardAsyncFixture } }; -using Tests = boost::mpl::vector< +using Tests = boost::mp11::mp_list< BasicNonLocal, NewFibLocal, InFaceLocal, diff --git a/tests/daemon/fw/strategy-ad-hoc-face.t.cpp b/tests/daemon/fw/strategy-ad-hoc-face.t.cpp index cd460545..ebd2623b 100644 --- a/tests/daemon/fw/strategy-ad-hoc-face.t.cpp +++ b/tests/daemon/fw/strategy-ad-hoc-face.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, @@ -37,7 +37,7 @@ #include "tests/daemon/global-io-fixture.hpp" #include "topology-tester.hpp" -#include +#include namespace nfd::tests { @@ -86,7 +86,7 @@ class AdHocTopologyFixture : public GlobalIoTimeFixture BOOST_AUTO_TEST_SUITE(Fw) BOOST_AUTO_TEST_SUITE(TestStrategyAdHocFace) -using Strategies = boost::mpl::vector< +using Strategies = boost::mp11::mp_list< AsfStrategy, BestRouteStrategy, MulticastStrategy, diff --git a/tests/daemon/fw/strategy-broadcast-medium.t.cpp b/tests/daemon/fw/strategy-broadcast-medium.t.cpp index 113faf56..e8e5acb4 100644 --- a/tests/daemon/fw/strategy-broadcast-medium.t.cpp +++ b/tests/daemon/fw/strategy-broadcast-medium.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, @@ -38,7 +38,7 @@ #include "tests/daemon/global-io-fixture.hpp" #include "topology-tester.hpp" -#include +#include namespace nfd::tests { @@ -89,7 +89,7 @@ class BroadcastMediumFixture : public GlobalIoTimeFixture BOOST_AUTO_TEST_SUITE(Fw) BOOST_AUTO_TEST_SUITE(TestStrategyBroadcastMedium) -using Strategies = boost::mpl::vector< +using Strategies = boost::mp11::mp_list< AsfStrategy, BestRouteStrategy, MulticastStrategy, diff --git a/tests/daemon/fw/strategy-instantiation.t.cpp b/tests/daemon/fw/strategy-instantiation.t.cpp index 0ac730cc..ca59f3ef 100644 --- a/tests/daemon/fw/strategy-instantiation.t.cpp +++ b/tests/daemon/fw/strategy-instantiation.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, @@ -37,7 +37,7 @@ #include "tests/test-common.hpp" -#include +#include namespace nfd::tests { @@ -46,23 +46,12 @@ using namespace nfd::fw; BOOST_AUTO_TEST_SUITE(Fw) BOOST_AUTO_TEST_SUITE(TestStrategyInstantiation) -template -class Test +template +struct Test { -public: using Strategy = S; - - static bool - canAcceptParameters() - { - return CanAcceptParameters; - } - - static uint64_t - getMinVersion() - { - return MinVersion; - } + static constexpr bool canAcceptParameters = CanAcceptParams; + static constexpr uint64_t minVersion = MinVer; static Name getVersionedStrategyName(uint64_t version) @@ -71,7 +60,7 @@ class Test } }; -using Tests = boost::mpl::vector< +using Tests = boost::mp11::mp_list< Test, Test, Test, @@ -89,26 +78,25 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(InstanceName, T, Tests) { BOOST_REQUIRE(T::Strategy::getStrategyName().at(-1).isVersion()); uint64_t maxVersion = T::Strategy::getStrategyName().at(-1).toVersion(); - BOOST_REQUIRE_LE(T::getMinVersion(), maxVersion); + BOOST_REQUIRE_LE(T::minVersion, maxVersion); FaceTable faceTable; Forwarder forwarder(faceTable); - for (uint64_t version = T::getMinVersion(); version <= maxVersion; ++version) { + for (auto version = T::minVersion; version <= maxVersion; ++version) { Name versionedName = T::getVersionedStrategyName(version); - unique_ptr instance; - BOOST_CHECK_NO_THROW(instance = make_unique(forwarder, versionedName)); + auto instance = make_unique(forwarder, versionedName); BOOST_CHECK_EQUAL(instance->getInstanceName(), versionedName); - if (!T::canAcceptParameters()) { + if (!T::canAcceptParameters) { Name nameWithParameters = Name(versionedName).append("param"); BOOST_CHECK_THROW(typename T::Strategy(forwarder, nameWithParameters), std::invalid_argument); } } - if (T::getMinVersion() > 0) { + if (T::minVersion > 0) { Name version0Name = T::getVersionedStrategyName(0); BOOST_CHECK_THROW(typename T::Strategy(forwarder, version0Name), std::invalid_argument); - Name earlyVersionName = T::getVersionedStrategyName(T::getMinVersion() - 1); + Name earlyVersionName = T::getVersionedStrategyName(T::minVersion - 1); BOOST_CHECK_THROW(typename T::Strategy(forwarder, earlyVersionName), std::invalid_argument); } @@ -145,7 +133,7 @@ class SuppressionParametersFixture Forwarder m_forwarder{m_faceTable}; }; -using StrategiesWithRetxSuppressionExponential = boost::mpl::vector< +using StrategiesWithRetxSuppressionExponential = boost::mp11::mp_list< AsfStrategy, BestRouteStrategy, MulticastStrategy diff --git a/tests/daemon/fw/strategy-nack-return.t.cpp b/tests/daemon/fw/strategy-nack-return.t.cpp index 4b6961d2..e7ed117f 100644 --- a/tests/daemon/fw/strategy-nack-return.t.cpp +++ b/tests/daemon/fw/strategy-nack-return.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, @@ -35,7 +35,7 @@ #include "topology-tester.hpp" #include "tests/daemon/face/dummy-face.hpp" -#include +#include namespace nfd::tests { @@ -83,7 +83,7 @@ class StrategyNackReturnFixture : public GlobalIoTimeFixture BOOST_AUTO_TEST_SUITE(Fw) BOOST_AUTO_TEST_SUITE(TestStrategyNackReturn) -using Strategies = boost::mpl::vector< +using Strategies = boost::mp11::mp_list< BestRouteStrategy, RandomStrategy >; @@ -282,7 +282,7 @@ struct NackReasonCombination static constexpr lp::NackReason expectedResult{R}; }; -using NackReasonCombinations = boost::mpl::vector< +using NackReasonCombinations = boost::mp11::mp_list< NackReasonCombination, NackReasonCombination, NackReasonCombination, diff --git a/tests/daemon/fw/strategy-no-route.t.cpp b/tests/daemon/fw/strategy-no-route.t.cpp index 3dfce2c3..2e70e0e6 100644 --- a/tests/daemon/fw/strategy-no-route.t.cpp +++ b/tests/daemon/fw/strategy-no-route.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, @@ -39,7 +39,7 @@ #include "choose-strategy.hpp" #include "strategy-tester.hpp" -#include +#include namespace nfd::tests { @@ -78,25 +78,16 @@ class StrategyNoRouteFixture : public GlobalIoTimeFixture BOOST_AUTO_TEST_SUITE(Fw) BOOST_AUTO_TEST_SUITE(TestStrategyNoRoute) -template -class Test -{ -public: - using Strategy = S; - using Case = C; -}; - template -class EmptyNextHopList +struct EmptyNextHopList { -public: - Name + static Name getInterestName() { return "/P"; } - void + static void insertFibEntry(StrategyNoRouteFixture* fixture) { fixture->fib.insert(Name()); @@ -104,16 +95,15 @@ class EmptyNextHopList }; template -class NextHopIsDownstream +struct NextHopIsDownstream { -public: - Name + static Name getInterestName() { return "/P"; } - void + static void insertFibEntry(StrategyNoRouteFixture* fixture) { fib::Entry* entry = fixture->fib.insert(Name()).first; @@ -122,16 +112,15 @@ class NextHopIsDownstream }; template -class NextHopViolatesScope +struct NextHopViolatesScope { -public: - Name + static Name getInterestName() { return "/localhop/P"; } - void + static void insertFibEntry(StrategyNoRouteFixture* fixture) { fib::Entry* entry = fixture->fib.insert("/localhop").first; @@ -140,27 +129,27 @@ class NextHopViolatesScope } }; -using Tests = boost::mpl::vector< - Test>, - Test>, - Test>, +using Tests = boost::mp11::mp_list< + boost::mp11::mp_list>, + boost::mp11::mp_list>, + boost::mp11::mp_list>, - Test>, - Test>, - Test>, + boost::mp11::mp_list>, + boost::mp11::mp_list>, + boost::mp11::mp_list>, - Test>, - Test>, - Test> + boost::mp11::mp_list>, + boost::mp11::mp_list>, + boost::mp11::mp_list> >; BOOST_FIXTURE_TEST_CASE_TEMPLATE(IncomingInterest, - T, Tests, StrategyNoRouteFixture) + T, Tests, StrategyNoRouteFixture>) { - typename T::Case scenario; - scenario.insertFibEntry(this); + using Scenario = boost::mp11::mp_second; + Scenario::insertFibEntry(this); - auto interest = makeInterest(scenario.getInterestName()); + auto interest = makeInterest(Scenario::getInterestName()); auto pitEntry = this->pit.insert(*interest).first; pitEntry->insertOrUpdateInRecord(*this->face1, *interest); diff --git a/tests/daemon/fw/strategy-scope-control.t.cpp b/tests/daemon/fw/strategy-scope-control.t.cpp index 392becbf..8bd96d10 100644 --- a/tests/daemon/fw/strategy-scope-control.t.cpp +++ b/tests/daemon/fw/strategy-scope-control.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, @@ -39,7 +39,7 @@ #include "choose-strategy.hpp" #include "strategy-tester.hpp" -#include +#include namespace nfd::tests { @@ -85,31 +85,15 @@ BOOST_AUTO_TEST_SUITE(Fw) BOOST_AUTO_TEST_SUITE(TestStrategyScopeControl) template -class Test +struct Test { -public: using Strategy = S; - - static bool - willRejectPitEntry() - { - return WillRejectPitEntry; - } - - static bool - willSendNackNoRoute() - { - return WillSendNackNoRoute; - } - - static bool - canProcessNack() - { - return CanProcessNack; - } + static constexpr bool canProcessNack = CanProcessNack; + static constexpr bool willRejectPitEntry = WillRejectPitEntry; + static constexpr bool willSendNackNoRoute = WillSendNackNoRoute; }; -using Tests = boost::mpl::vector< +using Tests = boost::mp11::mp_list< Test, Test, Test, @@ -148,11 +132,11 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToNonLocal, BOOST_REQUIRE(this->strategy.waitForAction( [&] { this->strategy.afterReceiveInterest(*interest, FaceEndpoint(*this->localFace3), pitEntry); }, - this->limitedIo, T::willRejectPitEntry() + T::willSendNackNoRoute())); + this->limitedIo, T::willRejectPitEntry + T::willSendNackNoRoute)); BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); - BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), T::willRejectPitEntry()); - if (T::willSendNackNoRoute()) { + BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), T::willRejectPitEntry); + if (T::willSendNackNoRoute) { BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); } @@ -191,11 +175,11 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopInterestToNonLocal, BOOST_REQUIRE(this->strategy.waitForAction( [&] { this->strategy.afterReceiveInterest(*interest, FaceEndpoint(*this->nonLocalFace1), pitEntry); }, - this->limitedIo, T::willRejectPitEntry() + T::willSendNackNoRoute())); + this->limitedIo, T::willRejectPitEntry + T::willSendNackNoRoute)); BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); - BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), T::willRejectPitEntry()); - if (T::willSendNackNoRoute()) { + BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), T::willRejectPitEntry); + if (T::willSendNackNoRoute) { BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); } @@ -237,11 +221,11 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostNackToNonLocal, BOOST_REQUIRE(this->strategy.waitForAction( [&] { this->strategy.afterReceiveNack(nack, FaceEndpoint(*this->localFace4), pitEntry); }, - this->limitedIo, T::canProcessNack())); + this->limitedIo, T::canProcessNack)); BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); - if (T::canProcessNack()) { + if (T::canProcessNack) { BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); } @@ -262,11 +246,11 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopNackToNonLocal, BOOST_REQUIRE(this->strategy.waitForAction( [&] { this->strategy.afterReceiveNack(nack, FaceEndpoint(*this->localFace4), pitEntry); }, - this->limitedIo, T::canProcessNack())); + this->limitedIo, T::canProcessNack)); BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); - if (T::canProcessNack()) { + if (T::canProcessNack) { BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); } diff --git a/tests/daemon/fw/unsolicited-data-policy.t.cpp b/tests/daemon/fw/unsolicited-data-policy.t.cpp index 67be5b20..c4a70974 100644 --- a/tests/daemon/fw/unsolicited-data-policy.t.cpp +++ b/tests/daemon/fw/unsolicited-data-policy.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, @@ -31,7 +31,7 @@ #include "tests/daemon/face/dummy-face.hpp" #include -#include +#include namespace nfd::tests { @@ -40,7 +40,8 @@ using namespace nfd::fw; class UnsolicitedDataPolicyFixture : public GlobalIoTimeFixture { protected: - /** \tparam Policy policy type, or void to keep default policy + /** + * \tparam Policy The policy type, or `void` to keep the default policy. */ template void @@ -89,15 +90,15 @@ BOOST_AUTO_TEST_CASE(GetPolicyNames) BOOST_CHECK_EQUAL(policyNames.count("admit-all"), 1); } -template +template struct FaceScopePolicyTest { - using PolicyType = Policy; - using ShouldAdmitLocal = std::bool_constant; - using ShouldAdmitNonLocal = std::bool_constant; + using PolicyType = P; + static constexpr bool shouldAdmitLocal = Local; + static constexpr bool shouldAdmitNonLocal = NonLocal; }; -using FaceScopePolicyTests = boost::mpl::vector< +using FaceScopePolicyTests = boost::mp11::mp_list< FaceScopePolicyTest, // default policy FaceScopePolicyTest, FaceScopePolicyTest, @@ -115,7 +116,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(FaceScopePolicy, T, FaceScopePolicyTests) auto data1 = makeData("/unsolicited-from-local"); forwarder.onIncomingData(*data1, FaceEndpoint(*face1)); - BOOST_CHECK_EQUAL(isInCs(*data1), T::ShouldAdmitLocal::value); + BOOST_CHECK_EQUAL(isInCs(*data1), T::shouldAdmitLocal); auto face2 = make_shared("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_NON_LOCAL); @@ -123,7 +124,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(FaceScopePolicy, T, FaceScopePolicyTests) auto data2 = makeData("/unsolicited-from-non-local"); forwarder.onIncomingData(*data2, FaceEndpoint(*face2)); - BOOST_CHECK_EQUAL(isInCs(*data2), T::ShouldAdmitNonLocal::value); + BOOST_CHECK_EQUAL(isInCs(*data2), T::shouldAdmitNonLocal); } BOOST_AUTO_TEST_SUITE_END() // TestUnsolicitedDataPolicy diff --git a/tests/daemon/mgmt/face-manager-create-face.t.cpp b/tests/daemon/mgmt/face-manager-create-face.t.cpp index 45ddc1f1..8f789c6b 100644 --- a/tests/daemon/mgmt/face-manager-create-face.t.cpp +++ b/tests/daemon/mgmt/face-manager-create-face.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, @@ -23,13 +23,13 @@ * NFD, e.g., in COPYING.md file. If not, see . */ -#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS -#define BOOST_MPL_LIMIT_VECTOR_SIZE 40 - #include "mgmt/face-manager.hpp" #include "face/generic-link-service.hpp" + #include "face-manager-command-fixture.hpp" +#include + namespace nfd::tests { BOOST_AUTO_TEST_SUITE(Mgmt) @@ -302,36 +302,35 @@ class FaceUriUnsupportedScheme } }; -namespace mpl = boost::mpl; - -// pairs of CreateCommand and Success/Failure status -using TestCases = mpl::vector< - mpl::pair>, - mpl::pair, - mpl::pair, - mpl::pair>, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair>, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair, - mpl::pair>, - mpl::pair, - mpl::pair>, - mpl::pair>, - mpl::pair>>; +// Pairs of CreateCommand and success/failure status +using TestCases = boost::mp11::mp_list< + boost::mp11::mp_list>, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list>, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list>, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list>, + boost::mp11::mp_list, + boost::mp11::mp_list>, + boost::mp11::mp_list>, + boost::mp11::mp_list> +>; BOOST_FIXTURE_TEST_CASE_TEMPLATE(NewFace, T, TestCases, FaceManagerCommandFixture) { - using FaceType = typename T::first; - using CreateResult = typename T::second; + using FaceType = boost::mp11::mp_first; + using CreateResult = boost::mp11::mp_second; Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", FaceType::getParameters()); diff --git a/tests/daemon/mgmt/face-manager-update-face.t.cpp b/tests/daemon/mgmt/face-manager-update-face.t.cpp index 60003805..ebc794ae 100644 --- a/tests/daemon/mgmt/face-manager-update-face.t.cpp +++ b/tests/daemon/mgmt/face-manager-update-face.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, @@ -31,17 +31,15 @@ #include -#include - #include +#include +#include namespace nfd::tests { BOOST_AUTO_TEST_SUITE(Mgmt) BOOST_AUTO_TEST_SUITE(TestFaceManager) -namespace mpl = boost::mpl; - class FaceManagerUpdateFixture : public FaceManagerCommandFixture { public: @@ -202,15 +200,15 @@ BOOST_AUTO_TEST_CASE(FaceDoesNotExist) }); } -using UpdatePersistencyTests = mpl::vector< - mpl::pair, CommandSuccess>, - mpl::pair, CommandFailure<409>> +using UpdatePersistencyTests = boost::mp11::mp_list< + boost::mp11::mp_list, CommandSuccess>, + boost::mp11::mp_list, CommandFailure<409>> >; BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdatePersistency, T, UpdatePersistencyTests, FaceManagerUpdateFixture) { - using TransportType = typename T::first; - using ResultType = typename T::second; + using TransportType = boost::mp11::mp_first; + using ResultType = boost::mp11::mp_second; auto face = make_shared(make_unique(), make_unique()); @@ -511,18 +509,18 @@ class UdpLocalFieldsEnableNoMaskBit } }; -using LocalFieldFaces = mpl::vector< - mpl::pair, - mpl::pair, - mpl::pair>, - mpl::pair, - mpl::pair +using LocalFieldFaces = boost::mp11::mp_list< + boost::mp11::mp_list, + boost::mp11::mp_list, + boost::mp11::mp_list>, + boost::mp11::mp_list, + boost::mp11::mp_list >; BOOST_AUTO_TEST_CASE_TEMPLATE(UpdateLocalFields, T, LocalFieldFaces) { - using TestType = typename T::first; - using ResultType = typename T::second; + using TestType = boost::mp11::mp_first; + using ResultType = boost::mp11::mp_second; createFace(TestType::getUri(), TestType::getPersistency(), {}, {}, TestType::getInitLocalFieldsEnabled()); diff --git a/tests/daemon/mgmt/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp index 65dcf05b..43c69dfa 100644 --- a/tests/daemon/mgmt/rib-manager.t.cpp +++ b/tests/daemon/mgmt/rib-manager.t.cpp @@ -32,6 +32,7 @@ #include #include +#include #include namespace nfd::tests { @@ -303,21 +304,21 @@ class AuthorizedRibManagerFixture : public RibManagerFixture } }; -template +template struct FixtureWithFormat : public Fixture { - static constexpr ndn::security::SignedInterestFormat signedInterestFmt = Format; + static constexpr ndn::security::SignedInterestFormat signedInterestFmt = Format::value; }; -using AllFixtures = boost::mpl::vector< - FixtureWithFormat, - FixtureWithFormat, - FixtureWithFormat, - FixtureWithFormat, - FixtureWithFormat, - FixtureWithFormat, - FixtureWithFormat, - FixtureWithFormat +using AllFixtures = boost::mp11::mp_product< + FixtureWithFormat, + boost::mp11::mp_list, + boost::mp11::mp_list_c >; BOOST_FIXTURE_TEST_CASE_TEMPLATE(CommandAuthorization, T, AllFixtures, T) diff --git a/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp b/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp index 85624c2a..996ff37b 100644 --- a/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp +++ b/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.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, @@ -32,6 +32,8 @@ #include #include +#include + namespace nfd::tests { using namespace nfd::rib; @@ -113,7 +115,7 @@ class AdvertiseFailureScenario } }; -using AdvertiseScenarios = boost::mpl::vector; +using AdvertiseScenarios = boost::mp11::mp_list; BOOST_AUTO_TEST_CASE_TEMPLATE(Advertise, Scenario, AdvertiseScenarios) { @@ -191,7 +193,7 @@ class WithdrawFailureScenario } }; -using WithdrawScenarios = boost::mpl::vector; +using WithdrawScenarios = boost::mp11::mp_list; BOOST_AUTO_TEST_CASE_TEMPLATE(Withdraw, Scenario, WithdrawScenarios) {