blob: 1a47780a045bcdfbefc7a3f4f760ea81167b3cbb [file] [log] [blame]
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -08001/**
2 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
4 * See COPYING for copyright and distribution information.
5 */
6
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -08007#include "management/ndnd-forwarding-entry.hpp"
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -08008
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -07009#include "boost-test.hpp"
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080010
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080011namespace ndn {
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080012namespace ndnd {
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080013
Alexander Afanasyev4b456282014-02-13 00:34:34 -080014const uint8_t FORWARDING_ENTRY[] = {0x81, 0x19, 0x83, 0x07, 0x73, 0x65, 0x6c, 0x66, 0x72, 0x65, 0x67,
15 0x07, 0x0b,
16 0x08, 0x01, 0x61,
17 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78,
18 0x8a, 0x01, 0x03};
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080019
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070020BOOST_AUTO_TEST_SUITE(ManagementTestNdndForwardingEntry)
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080021
22BOOST_AUTO_TEST_CASE (Encode)
23{
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070024 ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), time::milliseconds::min());
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080025 const Block &wire = forwardingEntry.wireEncode();
26
27 BOOST_REQUIRE_EQUAL_COLLECTIONS(FORWARDING_ENTRY, FORWARDING_ENTRY+sizeof(FORWARDING_ENTRY),
28 wire.begin(), wire.end());
29}
30
31BOOST_AUTO_TEST_CASE (Decode)
32{
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080033 ForwardingEntry forwardingEntry;
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070034
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080035 BOOST_REQUIRE_NO_THROW(forwardingEntry.wireDecode(Block(FORWARDING_ENTRY, sizeof(FORWARDING_ENTRY))));
36
37 BOOST_REQUIRE_EQUAL(forwardingEntry.getAction(), "selfreg");
38 BOOST_REQUIRE_EQUAL(forwardingEntry.getPrefix(), Name("/a/prefix"));
39 BOOST_REQUIRE_EQUAL(forwardingEntry.getFaceId(), -1);
40 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getActive(), true);
41 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getChildInherit(), true);
42 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getAdvertise(), false);
43 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLast(), false);
44 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCapture(), false);
45 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLocal(), false);
46 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getTap(), false);
47 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCaptureOk(), false);
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070048 BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), time::milliseconds::min());
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080049}
50
51BOOST_AUTO_TEST_SUITE_END()
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080052
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080053} // namespace ndnd
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080054} // namespace ndn