blob: 7e2066b6fe411d92d8db190386fce8d5540aa8f0 [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 Afanasyev6835ad82014-02-12 10:07:20 -080023const uint8_t FORWARDING_ENTRY[] = {0x81, 0x19, 0x83, 0x07, 0x73, 0x65, 0x6c, 0x66, 0x72, 0x65, 0x67, 0x01, 0x0b, 0x02, 0x01, 0x61, 0x02, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x8a, 0x01, 0x03};
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080024
25BOOST_AUTO_TEST_SUITE(TestForwardingEntry)
26
27BOOST_AUTO_TEST_CASE (Encode)
28{
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080029 ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), -1);
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080030 const Block &wire = forwardingEntry.wireEncode();
31
32 BOOST_REQUIRE_EQUAL_COLLECTIONS(FORWARDING_ENTRY, FORWARDING_ENTRY+sizeof(FORWARDING_ENTRY),
33 wire.begin(), wire.end());
34}
35
36BOOST_AUTO_TEST_CASE (Decode)
37{
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080038 ForwardingEntry forwardingEntry;
Alexander Afanasyev84c2bd42014-01-09 22:35:35 -080039
40 BOOST_REQUIRE_NO_THROW(forwardingEntry.wireDecode(Block(FORWARDING_ENTRY, sizeof(FORWARDING_ENTRY))));
41
42 BOOST_REQUIRE_EQUAL(forwardingEntry.getAction(), "selfreg");
43 BOOST_REQUIRE_EQUAL(forwardingEntry.getPrefix(), Name("/a/prefix"));
44 BOOST_REQUIRE_EQUAL(forwardingEntry.getFaceId(), -1);
45 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getActive(), true);
46 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getChildInherit(), true);
47 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getAdvertise(), false);
48 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLast(), false);
49 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCapture(), false);
50 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLocal(), false);
51 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getTap(), false);
52 BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCaptureOk(), false);
53 BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), -1);
54}
55
56BOOST_AUTO_TEST_SUITE_END()
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080057
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080058} // namespace ndnd
Alexander Afanasyev0abb2da2014-01-30 18:07:57 -080059} // namespace ndn