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 | |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 23 | const uint8_t FORWARDING_ENTRY[] = {0x81, 0x19, 0x83, 0x07, 0x73, 0x65, 0x6c, 0x66, 0x72, 0x65, 0x67, |
| 24 | 0x07, 0x0b, |
| 25 | 0x08, 0x01, 0x61, |
| 26 | 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 27 | 0x8a, 0x01, 0x03}; |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 28 | |
| 29 | BOOST_AUTO_TEST_SUITE(TestForwardingEntry) |
| 30 | |
| 31 | BOOST_AUTO_TEST_CASE (Encode) |
| 32 | { |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 33 | ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), time::milliseconds::min()); |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 34 | const Block &wire = forwardingEntry.wireEncode(); |
| 35 | |
| 36 | BOOST_REQUIRE_EQUAL_COLLECTIONS(FORWARDING_ENTRY, FORWARDING_ENTRY+sizeof(FORWARDING_ENTRY), |
| 37 | wire.begin(), wire.end()); |
| 38 | } |
| 39 | |
| 40 | BOOST_AUTO_TEST_CASE (Decode) |
| 41 | { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 42 | ForwardingEntry forwardingEntry; |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 43 | |
| 44 | BOOST_REQUIRE_NO_THROW(forwardingEntry.wireDecode(Block(FORWARDING_ENTRY, sizeof(FORWARDING_ENTRY)))); |
| 45 | |
| 46 | BOOST_REQUIRE_EQUAL(forwardingEntry.getAction(), "selfreg"); |
| 47 | BOOST_REQUIRE_EQUAL(forwardingEntry.getPrefix(), Name("/a/prefix")); |
| 48 | BOOST_REQUIRE_EQUAL(forwardingEntry.getFaceId(), -1); |
| 49 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getActive(), true); |
| 50 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getChildInherit(), true); |
| 51 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getAdvertise(), false); |
| 52 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLast(), false); |
| 53 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCapture(), false); |
| 54 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLocal(), false); |
| 55 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getTap(), false); |
| 56 | BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCaptureOk(), false); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 57 | BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), time::milliseconds::min()); |
Alexander Afanasyev | 84c2bd4 | 2014-01-09 22:35:35 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | BOOST_AUTO_TEST_SUITE_END() |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 61 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 62 | } // namespace ndnd |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 63 | } // namespace ndn |