Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 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. |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include "management/nfd-control-parameters.hpp" |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 14 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 15 | #include "boost-test.hpp" |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 16 | |
| 17 | namespace ndn { |
| 18 | namespace nfd { |
| 19 | |
Alexander Afanasyev | d1b5c41 | 2014-03-27 15:03:51 -0700 | [diff] [blame] | 20 | BOOST_AUTO_TEST_SUITE(ManagementTestNfdControlParameters) |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 21 | |
| 22 | BOOST_AUTO_TEST_CASE(FaceOptions) |
| 23 | { |
| 24 | ControlParameters parameters; |
| 25 | parameters.setUri("tcp4://192.0.2.1:6363"); |
| 26 | |
| 27 | Block wire = parameters.wireEncode(); |
| 28 | |
| 29 | ControlParameters decoded(wire); |
| 30 | BOOST_CHECK_EQUAL(decoded.getUri(), "tcp4://192.0.2.1:6363"); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 31 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 32 | BOOST_CHECK_EQUAL(decoded.hasName(), false); |
| 33 | BOOST_CHECK_EQUAL(decoded.hasFaceId(), false); |
| 34 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 35 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 36 | BOOST_CHECK_EQUAL(decoded.hasCost(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 37 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 38 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 39 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | BOOST_AUTO_TEST_CASE(FaceLocalControlOptions) |
| 43 | { |
| 44 | ControlParameters parameters; |
| 45 | parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 46 | |
| 47 | Block wire = parameters.wireEncode(); |
| 48 | |
| 49 | ControlParameters decoded(wire); |
| 50 | BOOST_CHECK_EQUAL(decoded.getLocalControlFeature(), LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 51 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 52 | BOOST_CHECK_EQUAL(decoded.hasName(), false); |
| 53 | BOOST_CHECK_EQUAL(decoded.hasFaceId(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 54 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 55 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
| 56 | BOOST_CHECK_EQUAL(decoded.hasCost(), false); |
| 57 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 58 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 59 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | BOOST_AUTO_TEST_CASE(FibOptions) |
| 63 | { |
| 64 | ControlParameters parameters; |
| 65 | parameters.setName("ndn:/example") |
| 66 | .setFaceId(4) |
| 67 | .setCost(555); |
| 68 | |
| 69 | Block wire = parameters.wireEncode(); |
| 70 | |
| 71 | ControlParameters decoded(wire); |
| 72 | BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example")); |
| 73 | BOOST_CHECK_EQUAL(decoded.getFaceId(), 4); |
| 74 | BOOST_CHECK_EQUAL(decoded.getCost(), 555); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 75 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 76 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 77 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
| 78 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
| 79 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 80 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 81 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | BOOST_AUTO_TEST_CASE(StrategyChoiceOptions) |
| 85 | { |
| 86 | ControlParameters parameters; |
| 87 | parameters.setName("ndn:/") |
| 88 | .setStrategy("ndn:/strategy/A"); |
| 89 | |
| 90 | Block wire = parameters.wireEncode(); |
| 91 | |
| 92 | ControlParameters decoded(wire); |
| 93 | BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/")); |
| 94 | BOOST_CHECK_EQUAL(decoded.getStrategy(), Name("ndn:/strategy/A")); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 95 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 96 | BOOST_CHECK_EQUAL(decoded.hasFaceId(), false); |
| 97 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
| 98 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 99 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 100 | BOOST_CHECK_EQUAL(decoded.hasCost(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 101 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
| 102 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
| 103 | } |
| 104 | |
| 105 | BOOST_AUTO_TEST_CASE(RibOptions) |
| 106 | { |
| 107 | ControlParameters parameters; |
| 108 | parameters.setName("ndn:/example") |
| 109 | .setFaceId(4) |
| 110 | .setOrigin(128) |
| 111 | .setCost(6) |
| 112 | .setFlags(0x01) |
| 113 | .setExpirationPeriod(time::milliseconds(1800000)); |
| 114 | |
| 115 | Block wire = parameters.wireEncode(); |
| 116 | |
| 117 | ControlParameters decoded(wire); |
| 118 | BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example")); |
| 119 | BOOST_CHECK_EQUAL(decoded.getFaceId(), 4); |
| 120 | BOOST_CHECK_EQUAL(decoded.getOrigin(), 128); |
| 121 | BOOST_CHECK_EQUAL(decoded.getCost(), 6); |
| 122 | BOOST_CHECK_EQUAL(decoded.getFlags(), 0x01); |
| 123 | BOOST_CHECK_EQUAL(decoded.getExpirationPeriod(), time::milliseconds(1800000)); |
| 124 | |
| 125 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
| 126 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
| 127 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | BOOST_AUTO_TEST_SUITE_END() |
| 131 | |
| 132 | } // namespace nfd |
| 133 | } // namespace ndn |