Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 1 | /** |
| 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 Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 7 | #include "management/ndnd-forwarding-entry.hpp" |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 8 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 9 | #include "boost-test.hpp" |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 10 | |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 11 | namespace ndn { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 12 | namespace ndnd { |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 13 | |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 14 | const 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 Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 19 | |
| 20 | BOOST_AUTO_TEST_SUITE(TestForwardingEntry) |
| 21 | |
| 22 | BOOST_AUTO_TEST_CASE (Encode) |
| 23 | { |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 24 | ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), time::milliseconds::min()); |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 25 | 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 | |
| 31 | BOOST_AUTO_TEST_CASE (Decode) |
| 32 | { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 33 | ForwardingEntry forwardingEntry; |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 34 | |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 35 | 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 Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 48 | BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), time::milliseconds::min()); |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | BOOST_AUTO_TEST_SUITE_END() |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 52 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 53 | } // namespace ndnd |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 54 | } // namespace ndn |