/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2012-2017 University of California, Los Angeles
 *
 * This file is part of ChronoSync, synchronization library for distributed realtime
 * applications for NDN.
 *
 * ChronoSync 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.
 *
 * ChronoSync 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
 * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "leaf.hpp"
#include "boost-test.hpp"
#include "leaf-container.hpp"

#include <ndn-cxx/encoding/buffer-stream.hpp>
#include <ndn-cxx/util/string-helper.hpp>

namespace chronosync {
namespace test {

BOOST_AUTO_TEST_SUITE(LeafTests)

BOOST_AUTO_TEST_CASE(LeafBasic)
{
  Name userPrefix("/test/name");
  BOOST_CHECK_NO_THROW(Leaf leaf(userPrefix, 1, 10));

  Leaf leaf(userPrefix, 1, 10);
  Name sessionName = userPrefix;
  sessionName.appendNumber(1);
  BOOST_CHECK_EQUAL(leaf.getSessionName(), sessionName);
  BOOST_CHECK_EQUAL(leaf.getSeq(), 10);

  leaf.setSeq(9);
  BOOST_CHECK_EQUAL(leaf.getSeq(), 10);
  leaf.setSeq(11);
  BOOST_CHECK_EQUAL(leaf.getSeq(), 11);
}

BOOST_AUTO_TEST_CASE(LeafDigest)
{
  std::string result = "05fe7f728d3341e9eff82526277b02171044124d0a52e8c4610982261c20de2b";

  Name userPrefix("/test/name");
  Leaf leaf(userPrefix, 1, 10);

  BOOST_CHECK_NO_THROW(leaf.getDigest());

  ndn::ConstBufferPtr digest = leaf.getDigest();
  BOOST_CHECK_EQUAL(result, ndn::toHex(digest->buf(), digest->size(), false));
}

BOOST_AUTO_TEST_CASE(Container)
{
  LeafPtr leaf1 = make_shared<Leaf>(Name("/test/name"), 1, 10);
  LeafPtr leaf2 = make_shared<Leaf>(Name("/test/name"), 2, 10);

  LeafContainer container;

  container.insert(leaf1);
  container.insert(leaf2);

  Name idx1("/test/name");
  idx1.appendNumber(1);

  Name idx2("/test/name");
  idx2.appendNumber(2);

  Name idx3("/test/name");
  idx3.appendNumber(3);

  Name idx4("/test/mane");
  idx4.appendNumber(4);

  LeafContainer::index<hashed>::type& hashedIndex = container.get<hashed>();

  BOOST_CHECK_EQUAL(container.get<ordered>().size(), 2);
  BOOST_CHECK_EQUAL(container.get<hashed>().size(), 2);
  BOOST_CHECK(container.find(idx1) != container.end());
  BOOST_CHECK(container.find(idx2) != container.end());
  BOOST_CHECK(container.find(idx3) == container.end());

  BOOST_CHECK(hashedIndex.find(idx1) != hashedIndex.end());
  BOOST_CHECK(hashedIndex.find(idx2) != hashedIndex.end());
  BOOST_CHECK(hashedIndex.find(idx3) == hashedIndex.end());

  LeafPtr leaf3 = make_shared<Leaf>(Name("/test/mane"), 3, 10);
  container.insert(leaf3);

  Name idx0("/test/mane");
  idx0.appendNumber(3);

  LeafContainer::index<ordered>::type::iterator it = container.get<ordered>().begin();
  BOOST_CHECK_EQUAL((*it)->getSessionName(), idx0);
  it++;
  BOOST_REQUIRE(it != container.get<ordered>().end());
  BOOST_CHECK_EQUAL((*it)->getSessionName(), idx1);
  it++;
  BOOST_REQUIRE(it != container.get<ordered>().end());
  BOOST_CHECK_EQUAL((*it)->getSessionName(), idx2);


  BOOST_CHECK(hashedIndex.find(idx0) != hashedIndex.end());
  BOOST_CHECK(hashedIndex.find(idx1) != hashedIndex.end());
  BOOST_CHECK(hashedIndex.find(idx2) != hashedIndex.end());
  BOOST_CHECK(hashedIndex.find(idx4) == hashedIndex.end());
}

BOOST_AUTO_TEST_SUITE_END()

} // namespace test
} // namespace chronosync
