blob: 28c9f1bd551ba43772d32aacb40889f2f686fc09 [file] [log] [blame]
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -08002/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080011 */
12
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080013#include "management/ndnd-forwarding-entry.hpp"
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080014
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070015#include "boost-test.hpp"
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080016
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080017namespace ndn {
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080018namespace ndnd {
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080019
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070020const uint8_t FORWARDING_ENTRY[] = {
21 0x81, 0x19, 0x83, 0x07, 0x73, 0x65, 0x6c, 0x66, 0x72, 0x65, 0x67,
22 0x07, 0x0b, 0x08, 0x01, 0x61, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66,
23 0x69, 0x78, 0x8a, 0x01, 0x03};
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080024
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070025BOOST_AUTO_TEST_SUITE(ManagementTestNdndForwardingEntry)
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080026
27BOOST_AUTO_TEST_CASE (Encode)
28{
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070029 ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(),
30 time::milliseconds::min());
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080031 const Block &wire = forwardingEntry.wireEncode();
32
33 BOOST_REQUIRE_EQUAL_COLLECTIONS(FORWARDING_ENTRY, FORWARDING_ENTRY+sizeof(FORWARDING_ENTRY),
34 wire.begin(), wire.end());
35}
36
37BOOST_AUTO_TEST_CASE (Decode)
38{
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080039 ForwardingEntry forwardingEntry;
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070040
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070041 BOOST_REQUIRE_NO_THROW(forwardingEntry.wireDecode(Block(FORWARDING_ENTRY,
42 sizeof(FORWARDING_ENTRY))));
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080043
44 BOOST_REQUIRE_EQUAL(forwardingEntry.getAction(), "selfreg");
45 BOOST_REQUIRE_EQUAL(forwardingEntry.getPrefix(), Name("/a/prefix"));
46 BOOST_REQUIRE_EQUAL(forwardingEntry.getFaceId(), -1);
47 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getActive(), true);
48 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getChildInherit(), true);
49 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getAdvertise(), false);
50 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLast(), false);
51 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCapture(), false);
52 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLocal(), false);
53 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getTap(), false);
54 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCaptureOk(), false);
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070055 BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), time::milliseconds::min());
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080056}
57
58BOOST_AUTO_TEST_SUITE_END()
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080059
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080060} // namespace ndnd
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080061} // namespace ndn