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 | /** |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2015 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 { |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 28 | namespace tests { |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 29 | |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 30 | BOOST_AUTO_TEST_SUITE(ManagementNfdControlParameters) |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 31 | |
| 32 | BOOST_AUTO_TEST_CASE(FaceOptions) |
| 33 | { |
| 34 | ControlParameters parameters; |
| 35 | parameters.setUri("tcp4://192.0.2.1:6363"); |
| 36 | |
| 37 | Block wire = parameters.wireEncode(); |
| 38 | |
| 39 | ControlParameters decoded(wire); |
| 40 | BOOST_CHECK_EQUAL(decoded.getUri(), "tcp4://192.0.2.1:6363"); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 41 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 42 | BOOST_CHECK_EQUAL(decoded.hasName(), false); |
| 43 | BOOST_CHECK_EQUAL(decoded.hasFaceId(), false); |
| 44 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 45 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 46 | BOOST_CHECK_EQUAL(decoded.hasCost(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 47 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 48 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 49 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | BOOST_AUTO_TEST_CASE(FaceLocalControlOptions) |
| 53 | { |
| 54 | ControlParameters parameters; |
| 55 | parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 56 | |
| 57 | Block wire = parameters.wireEncode(); |
| 58 | |
| 59 | ControlParameters decoded(wire); |
| 60 | BOOST_CHECK_EQUAL(decoded.getLocalControlFeature(), LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 61 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 62 | BOOST_CHECK_EQUAL(decoded.hasName(), false); |
| 63 | BOOST_CHECK_EQUAL(decoded.hasFaceId(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 64 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 65 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
| 66 | BOOST_CHECK_EQUAL(decoded.hasCost(), false); |
| 67 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 68 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 69 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | BOOST_AUTO_TEST_CASE(FibOptions) |
| 73 | { |
| 74 | ControlParameters parameters; |
| 75 | parameters.setName("ndn:/example") |
| 76 | .setFaceId(4) |
| 77 | .setCost(555); |
| 78 | |
| 79 | Block wire = parameters.wireEncode(); |
| 80 | |
| 81 | ControlParameters decoded(wire); |
| 82 | BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example")); |
| 83 | BOOST_CHECK_EQUAL(decoded.getFaceId(), 4); |
| 84 | BOOST_CHECK_EQUAL(decoded.getCost(), 555); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 85 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 86 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 87 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
| 88 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
| 89 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 90 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 91 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | BOOST_AUTO_TEST_CASE(StrategyChoiceOptions) |
| 95 | { |
| 96 | ControlParameters parameters; |
| 97 | parameters.setName("ndn:/") |
| 98 | .setStrategy("ndn:/strategy/A"); |
| 99 | |
| 100 | Block wire = parameters.wireEncode(); |
| 101 | |
| 102 | ControlParameters decoded(wire); |
| 103 | BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/")); |
| 104 | BOOST_CHECK_EQUAL(decoded.getStrategy(), Name("ndn:/strategy/A")); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 105 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 106 | BOOST_CHECK_EQUAL(decoded.hasFaceId(), false); |
| 107 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
| 108 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 109 | BOOST_CHECK_EQUAL(decoded.hasOrigin(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 110 | BOOST_CHECK_EQUAL(decoded.hasCost(), false); |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 111 | BOOST_CHECK_EQUAL(decoded.hasFlags(), false); |
| 112 | BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false); |
| 113 | } |
| 114 | |
| 115 | BOOST_AUTO_TEST_CASE(RibOptions) |
| 116 | { |
| 117 | ControlParameters parameters; |
| 118 | parameters.setName("ndn:/example") |
| 119 | .setFaceId(4) |
| 120 | .setOrigin(128) |
| 121 | .setCost(6) |
| 122 | .setFlags(0x01) |
| 123 | .setExpirationPeriod(time::milliseconds(1800000)); |
| 124 | |
| 125 | Block wire = parameters.wireEncode(); |
| 126 | |
| 127 | ControlParameters decoded(wire); |
| 128 | BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example")); |
| 129 | BOOST_CHECK_EQUAL(decoded.getFaceId(), 4); |
| 130 | BOOST_CHECK_EQUAL(decoded.getOrigin(), 128); |
| 131 | BOOST_CHECK_EQUAL(decoded.getCost(), 6); |
| 132 | BOOST_CHECK_EQUAL(decoded.getFlags(), 0x01); |
| 133 | BOOST_CHECK_EQUAL(decoded.getExpirationPeriod(), time::milliseconds(1800000)); |
| 134 | |
| 135 | BOOST_CHECK_EQUAL(decoded.hasUri(), false); |
| 136 | BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false); |
| 137 | BOOST_CHECK_EQUAL(decoded.hasStrategy(), false); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | BOOST_AUTO_TEST_SUITE_END() |
| 141 | |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 142 | } // namespace tests |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 143 | } // namespace nfd |
| 144 | } // namespace ndn |