Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2014 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include "management/nfd-control-parameters.hpp" |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 23 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 24 | #include "boost-test.hpp" |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 25 | |
| 26 | namespace ndn { |
| 27 | namespace nfd { |
| 28 | |
Alexander Afanasyev | d1b5c41 | 2014-03-27 15:03:51 -0700 | [diff] [blame] | 29 | BOOST_AUTO_TEST_SUITE(ManagementTestNfdControlParameters) |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 30 | |
| 31 | BOOST_AUTO_TEST_CASE(FaceOptions) |
| 32 | { |
| 33 | ControlParameters parameters; |
| 34 | parameters.setUri("tcp4://192.0.2.1:6363"); |
| 35 | |
| 36 | Block wire = parameters.wireEncode(); |
| 37 | |
| 38 | ControlParameters decoded(wire); |
| 39 | BOOST_CHECK_EQUAL(decoded.getUri(), "tcp4://192.0.2.1:6363"); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 40 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 41 | BOOST_CHECK_EQUAL(decoded.hasName(), false); |
| 42 | BOOST_CHECK_EQUAL(decoded.hasFaceId(), false); |
| 43 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 44 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 45 | BOOST_CHECK_EQUAL(decoded.hasCost(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 46 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 47 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 48 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | BOOST_AUTO_TEST_CASE(FaceLocalControlOptions) |
| 52 | { |
| 53 | ControlParameters parameters; |
| 54 | parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 55 | |
| 56 | Block wire = parameters.wireEncode(); |
| 57 | |
| 58 | ControlParameters decoded(wire); |
| 59 | BOOST_CHECK_EQUAL(decoded.getLocalControlFeature(), LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 60 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 61 | BOOST_CHECK_EQUAL(decoded.hasName(), false); |
| 62 | BOOST_CHECK_EQUAL(decoded.hasFaceId(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 63 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 64 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
| 65 | BOOST_CHECK_EQUAL(decoded.hasCost(), false); |
| 66 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 67 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 68 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | BOOST_AUTO_TEST_CASE(FibOptions) |
| 72 | { |
| 73 | ControlParameters parameters; |
| 74 | parameters.setName("ndn:/example") |
| 75 | .setFaceId(4) |
| 76 | .setCost(555); |
| 77 | |
| 78 | Block wire = parameters.wireEncode(); |
| 79 | |
| 80 | ControlParameters decoded(wire); |
| 81 | BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example")); |
| 82 | BOOST_CHECK_EQUAL(decoded.getFaceId(), 4); |
| 83 | BOOST_CHECK_EQUAL(decoded.getCost(), 555); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 84 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 85 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 86 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
| 87 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
| 88 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 89 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 90 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | BOOST_AUTO_TEST_CASE(StrategyChoiceOptions) |
| 94 | { |
| 95 | ControlParameters parameters; |
| 96 | parameters.setName("ndn:/") |
| 97 | .setStrategy("ndn:/strategy/A"); |
| 98 | |
| 99 | Block wire = parameters.wireEncode(); |
| 100 | |
| 101 | ControlParameters decoded(wire); |
| 102 | BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/")); |
| 103 | BOOST_CHECK_EQUAL(decoded.getStrategy(), Name("ndn:/strategy/A")); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 104 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 105 | BOOST_CHECK_EQUAL(decoded.hasFaceId(), false); |
| 106 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
| 107 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 108 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 109 | BOOST_CHECK_EQUAL(decoded.hasCost(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 110 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
| 111 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
| 112 | } |
| 113 | |
| 114 | BOOST_AUTO_TEST_CASE(RibOptions) |
| 115 | { |
| 116 | ControlParameters parameters; |
| 117 | parameters.setName("ndn:/example") |
| 118 | .setFaceId(4) |
| 119 | .setOrigin(128) |
| 120 | .setCost(6) |
| 121 | .setFlags(0x01) |
| 122 | .setExpirationPeriod(time::milliseconds(1800000)); |
| 123 | |
| 124 | Block wire = parameters.wireEncode(); |
| 125 | |
| 126 | ControlParameters decoded(wire); |
| 127 | BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example")); |
| 128 | BOOST_CHECK_EQUAL(decoded.getFaceId(), 4); |
| 129 | BOOST_CHECK_EQUAL(decoded.getOrigin(), 128); |
| 130 | BOOST_CHECK_EQUAL(decoded.getCost(), 6); |
| 131 | BOOST_CHECK_EQUAL(decoded.getFlags(), 0x01); |
| 132 | BOOST_CHECK_EQUAL(decoded.getExpirationPeriod(), time::milliseconds(1800000)); |
| 133 | |
| 134 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
| 135 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
| 136 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | BOOST_AUTO_TEST_SUITE_END() |
| 140 | |
| 141 | } // namespace nfd |
| 142 | } // namespace ndn |