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 | |
| 7 | #include <boost/test/unit_test.hpp> |
| 8 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 9 | #include "management/ndnd-forwarding-entry.hpp" |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 10 | |
| 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 | |
| 19 | using namespace std; |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 20 | namespace ndn { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 21 | namespace ndnd { |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 22 | |
| 23 | const uint8_t FORWARDING_ENTRY[] = {0x81, 0x19, 0x83, 0x07, 0x73, 0x65, 0x6c, 0x66, 0x72, 0x65, 0x67, 0x03, 0x0b, 0x04, 0x01, 0x61, 0x04, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x8a, 0x01, 0x03}; |
| 24 | |
| 25 | BOOST_AUTO_TEST_SUITE(TestForwardingEntry) |
| 26 | |
| 27 | BOOST_AUTO_TEST_CASE (Encode) |
| 28 | { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 29 | ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), -1); |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 30 | 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 | |
| 36 | BOOST_AUTO_TEST_CASE (Decode) |
| 37 | { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 38 | ForwardingEntry forwardingEntry; |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 39 | |
| 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 | |
| 56 | BOOST_AUTO_TEST_SUITE_END() |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 57 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 58 | } // namespace ndnd |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 59 | } // namespace ndn |