Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 3 | * 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 Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 11 | */ |
| 12 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 13 | #include "management/ndnd-forwarding-entry.hpp" |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 14 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 15 | #include "boost-test.hpp" |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 16 | |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 17 | namespace ndn { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 18 | namespace ndnd { |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 19 | |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 20 | const 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 Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 24 | |
Alexander Afanasyev | d1b5c41 | 2014-03-27 15:03:51 -0700 | [diff] [blame] | 25 | BOOST_AUTO_TEST_SUITE(ManagementTestNdndForwardingEntry) |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 26 | |
| 27 | BOOST_AUTO_TEST_CASE (Encode) |
| 28 | { |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 29 | ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), |
| 30 | time::milliseconds::min()); |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 31 | 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 | |
| 37 | BOOST_AUTO_TEST_CASE (Decode) |
| 38 | { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 39 | ForwardingEntry forwardingEntry; |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 40 | |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame^] | 41 | BOOST_REQUIRE_NO_THROW(forwardingEntry.wireDecode(Block(FORWARDING_ENTRY, |
| 42 | sizeof(FORWARDING_ENTRY)))); |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 43 | |
| 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 Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 55 | BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), time::milliseconds::min()); |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | BOOST_AUTO_TEST_SUITE_END() |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 59 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 60 | } // namespace ndnd |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 61 | } // namespace ndn |