/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2014-2022,  Regents of the University of California,
 *                           Arizona Board of Regents,
 *                           Colorado State University,
 *                           University Pierre & Marie Curie, Sorbonne University,
 *                           Washington University in St. Louis,
 *                           Beijing Institute of Technology,
 *                           The University of Memphis.
 *
 * This file is part of ndn-tools (Named Data Networking Essential Tools).
 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
 *
 * ndn-tools is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * ndn-tools, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef NDN_TOOLS_TESTS_TEST_COMMON_HPP
#define NDN_TOOLS_TESTS_TEST_COMMON_HPP

#include "core/common.hpp"
#include "tests/boost-test.hpp"

namespace ndn::tests {

/**
 * \brief Create an Interest
 */
shared_ptr<Interest>
makeInterest(const Name& name, bool canBePrefix = false,
             optional<time::milliseconds> lifetime = nullopt,
             optional<Interest::Nonce> nonce = nullopt);

/**
 * \brief Create a Data with a null (i.e., empty) signature
 *
 * If a "real" signature is desired, use KeyChainFixture and sign again with `m_keyChain`.
 */
shared_ptr<Data>
makeData(const Name& name);

/**
 * \brief Add a null signature to \p data
 */
Data&
signData(Data& data);

/**
 * \brief Add a null signature to \p data
 */
inline shared_ptr<Data>
signData(shared_ptr<Data> data)
{
  signData(*data);
  return data;
}

/**
 * \brief Create a Nack
 */
lp::Nack
makeNack(Interest interest, lp::NackReason reason);

/**
 * \brief Replace a name component in a packet
 * \param[inout] pkt the packet
 * \param index the index of the name component to replace
 * \param args arguments to name::Component constructor
 */
template<typename Packet, typename ...Args>
void
setNameComponent(Packet& pkt, ssize_t index, Args&& ...args)
{
  Name name = pkt.getName();
  name.set(index, name::Component(std::forward<Args>(args)...));
  pkt.setName(name);
}

} // namespace ndn::tests

#endif // NDN_TOOLS_TESTS_TEST_COMMON_HPP
