blob: 7ad5c944e107866eb7c7f79705d8a4355808095b [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
7#include <boost/test/unit_test.hpp>
8
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -08009#include "management/ndnd-forwarding-entry.hpp"
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080010
11#if __clang__
12#pragma clang diagnostic push
13#pragma clang diagnostic ignored "-Wtautological-compare"
14#endif
15
16#include <fstream>
17#include <boost/test/output_test_stream.hpp>
18
19using namespace std;
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080020namespace ndn {
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080021namespace ndnd {
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080022
Alexander Afanasyev4b456282014-02-13 00:34:34 -080023const uint8_t FORWARDING_ENTRY[] = {0x81, 0x19, 0x83, 0x07, 0x73, 0x65, 0x6c, 0x66, 0x72, 0x65, 0x67,
24 0x07, 0x0b,
25 0x08, 0x01, 0x61,
26 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78,
27 0x8a, 0x01, 0x03};
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080028
29BOOST_AUTO_TEST_SUITE(TestForwardingEntry)
30
31BOOST_AUTO_TEST_CASE (Encode)
32{
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070033 ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), time::milliseconds::min());
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080034 const Block &wire = forwardingEntry.wireEncode();
35
36 BOOST_REQUIRE_EQUAL_COLLECTIONS(FORWARDING_ENTRY, FORWARDING_ENTRY+sizeof(FORWARDING_ENTRY),
37 wire.begin(), wire.end());
38}
39
40BOOST_AUTO_TEST_CASE (Decode)
41{
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080042 ForwardingEntry forwardingEntry;
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080043
44 BOOST_REQUIRE_NO_THROW(forwardingEntry.wireDecode(Block(FORWARDING_ENTRY, sizeof(FORWARDING_ENTRY))));
45
46 BOOST_REQUIRE_EQUAL(forwardingEntry.getAction(), "selfreg");
47 BOOST_REQUIRE_EQUAL(forwardingEntry.getPrefix(), Name("/a/prefix"));
48 BOOST_REQUIRE_EQUAL(forwardingEntry.getFaceId(), -1);
49 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getActive(), true);
50 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getChildInherit(), true);
51 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getAdvertise(), false);
52 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLast(), false);
53 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCapture(), false);
54 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLocal(), false);
55 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getTap(), false);
56 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCaptureOk(), false);
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070057 BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), time::milliseconds::min());
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080058}
59
60BOOST_AUTO_TEST_SUITE_END()
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080061
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080062} // namespace ndnd
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080063} // namespace ndn