/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014-2017,  The University of Memphis,
 *                           Regents of the University of California
 *
 * This file is part of NLSR (Named-data Link State Routing).
 * See AUTHORS.md for complete list of NLSR authors and contributors.
 *
 * NLSR 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.
 *
 * NLSR 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
 * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 *
 * \author Ashlesh Gawande <agawande@memphis.edu>
 *
 **/
#include "adjacent.hpp"
#include <boost/test/unit_test.hpp>

namespace nlsr {

namespace test {

using namespace std;

BOOST_AUTO_TEST_SUITE(TestAdjacent)

BOOST_AUTO_TEST_CASE(OperatorEquals)
{
  const ndn::Name ADJ_NAME_1 = "name1";
  const ndn::FaceUri ADJ_URI_1 = ndn::FaceUri("udp4://10.0.0.1:8000");
  const double ADJ_LINK_COST_1 = 1;
  Adjacent adjacent1(ADJ_NAME_1);
  Adjacent adjacent2(ADJ_NAME_1);
  adjacent1.setFaceUri(ADJ_URI_1);
  adjacent2.setFaceUri(ADJ_URI_1);
  adjacent1.setLinkCost(ADJ_LINK_COST_1);
  adjacent2.setLinkCost(ADJ_LINK_COST_1);

  BOOST_CHECK(adjacent1 == adjacent2);
}

BOOST_AUTO_TEST_CASE(OperatorLessThan)
{
  const ndn::Name ADJ_NAME_1 = "name1";
  const double ADJ_LINK_COST_1 = 1;
  const ndn::Name ADJ_NAME_2 = "name2";
  const double ADJ_LINK_COST_2 = 2;
  Adjacent adjacent1(ADJ_NAME_1);
  Adjacent adjacent2(ADJ_NAME_1);
  adjacent1.setLinkCost(ADJ_LINK_COST_1);
  adjacent2.setLinkCost(ADJ_LINK_COST_2);

  BOOST_CHECK(adjacent1 < adjacent2);

  Adjacent adjacent3(ADJ_NAME_2);
  adjacent3.setLinkCost(ADJ_LINK_COST_1);

  BOOST_CHECK(adjacent1 < adjacent3);
}

BOOST_AUTO_TEST_CASE(Accessors)
{
  const ndn::Name ADJ_NAME_1 = "name1";
  Adjacent adjacent1(ADJ_NAME_1);

  // Link cost should always be rounded up to the nearest integer.
  // The library only acceps integral values for prefix registration.
  adjacent1.setLinkCost(10.1);

  BOOST_CHECK_EQUAL(adjacent1.getName(), "name1");
  BOOST_CHECK_EQUAL(adjacent1.getLinkCost(), 11);
}

BOOST_AUTO_TEST_CASE(compareFaceUri)
{
  const ndn::Name ADJ_NAME_1 = "name1";
  const ndn::Name ADJ_NAME_2 = "name2";
  const ndn::FaceUri ADJ_URI_1 = ndn::FaceUri("udp4://10.0.0.1:8000");
  Adjacent adjacent1(ADJ_NAME_1);
  Adjacent adjacent2(ADJ_NAME_2);
  adjacent1.setFaceUri(ADJ_URI_1);
  adjacent2.setFaceUri(ADJ_URI_1);

  BOOST_CHECK(adjacent1.compareFaceUri(adjacent2.getFaceUri()));
}

BOOST_AUTO_TEST_CASE(compareFaceId)
{
  const ndn::Name ADJ_NAME_1 = "name1";
  const ndn::Name ADJ_NAME_2 = "name2";
  const uint64_t ADJ_FACEID_1 = 1;
  Adjacent adjacent1(ADJ_NAME_1);
  Adjacent adjacent2(ADJ_NAME_2);
  adjacent1.setFaceId(ADJ_FACEID_1);
  adjacent2.setFaceId(ADJ_FACEID_1);

  BOOST_CHECK(adjacent1.compareFaceId(adjacent2.getFaceId()));
}

BOOST_AUTO_TEST_SUITE_END()

} // namespace test
} // namespace nlsr
