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