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 | 09c613f | 2014-01-29 00:23:58 -0800 | [diff] [blame] | 9 | #include "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 | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 21 | |
| 22 | 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}; |
| 23 | |
| 24 | BOOST_AUTO_TEST_SUITE(TestForwardingEntry) |
| 25 | |
| 26 | BOOST_AUTO_TEST_CASE (Encode) |
| 27 | { |
| 28 | ndn::ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), -1); |
| 29 | const Block &wire = forwardingEntry.wireEncode(); |
| 30 | |
| 31 | BOOST_REQUIRE_EQUAL_COLLECTIONS(FORWARDING_ENTRY, FORWARDING_ENTRY+sizeof(FORWARDING_ENTRY), |
| 32 | wire.begin(), wire.end()); |
| 33 | } |
| 34 | |
| 35 | BOOST_AUTO_TEST_CASE (Decode) |
| 36 | { |
| 37 | ndn::ForwardingEntry forwardingEntry; |
| 38 | |
| 39 | BOOST_REQUIRE_NO_THROW(forwardingEntry.wireDecode(Block(FORWARDING_ENTRY, sizeof(FORWARDING_ENTRY)))); |
| 40 | |
| 41 | BOOST_REQUIRE_EQUAL(forwardingEntry.getAction(), "selfreg"); |
| 42 | BOOST_REQUIRE_EQUAL(forwardingEntry.getPrefix(), Name("/a/prefix")); |
| 43 | BOOST_REQUIRE_EQUAL(forwardingEntry.getFaceId(), -1); |
| 44 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getActive(), true); |
| 45 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getChildInherit(), true); |
| 46 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getAdvertise(), false); |
| 47 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLast(), false); |
| 48 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCapture(), false); |
| 49 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLocal(), false); |
| 50 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getTap(), false); |
| 51 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCaptureOk(), false); |
| 52 | BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), -1); |
| 53 | } |
| 54 | |
| 55 | BOOST_AUTO_TEST_SUITE_END() |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 56 | |
| 57 | } // namespace ndn |