blob: d8c203b5c21b946ec212a24eebb700862e3dca00 [file] [log] [blame]
Junxiao Shibc19b372014-03-23 16:59:25 -07001/* -*- 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 Shibc19b372014-03-23 16:59:25 -07008
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -07009#include "boost-test.hpp"
Junxiao Shibc19b372014-03-23 16:59:25 -070010
11namespace ndn {
12namespace nfd {
13
14BOOST_AUTO_TEST_SUITE(NfdControlParameters)
15
16BOOST_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");
25 BOOST_CHECK_EQUAL(decoded.hasName(), false);
26 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
27 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
28 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
29 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
30}
31
32BOOST_AUTO_TEST_CASE(FaceLocalControlOptions)
33{
34 ControlParameters parameters;
35 parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
36
37 Block wire = parameters.wireEncode();
38
39 ControlParameters decoded(wire);
40 BOOST_CHECK_EQUAL(decoded.getLocalControlFeature(), LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
41 BOOST_CHECK_EQUAL(decoded.hasName(), false);
42 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
43 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
44 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
45 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
46}
47
48BOOST_AUTO_TEST_CASE(FibOptions)
49{
50 ControlParameters parameters;
51 parameters.setName("ndn:/example")
52 .setFaceId(4)
53 .setCost(555);
54
55 Block wire = parameters.wireEncode();
56
57 ControlParameters decoded(wire);
58 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example"));
59 BOOST_CHECK_EQUAL(decoded.getFaceId(), 4);
60 BOOST_CHECK_EQUAL(decoded.getCost(), 555);
61 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
62 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
63 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
64}
65
66BOOST_AUTO_TEST_CASE(StrategyChoiceOptions)
67{
68 ControlParameters parameters;
69 parameters.setName("ndn:/")
70 .setStrategy("ndn:/strategy/A");
71
72 Block wire = parameters.wireEncode();
73
74 ControlParameters decoded(wire);
75 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/"));
76 BOOST_CHECK_EQUAL(decoded.getStrategy(), Name("ndn:/strategy/A"));
77 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
78 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
79 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
80 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
81}
82
83BOOST_AUTO_TEST_SUITE_END()
84
85} // namespace nfd
86} // namespace ndn