blob: d5320b1898c33fff50588cfdc576f05e78a88505 [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"
8// Having a separate compilation unit is necessary to ensure .hpp can compile on its own.
9
10#include <boost/test/unit_test.hpp>
11
12namespace ndn {
13namespace nfd {
14
15BOOST_AUTO_TEST_SUITE(NfdControlParameters)
16
17BOOST_AUTO_TEST_CASE(FaceOptions)
18{
19 ControlParameters parameters;
20 parameters.setUri("tcp4://192.0.2.1:6363");
21
22 Block wire = parameters.wireEncode();
23
24 ControlParameters decoded(wire);
25 BOOST_CHECK_EQUAL(decoded.getUri(), "tcp4://192.0.2.1:6363");
26 BOOST_CHECK_EQUAL(decoded.hasName(), false);
27 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
28 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
29 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
30 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
31}
32
33BOOST_AUTO_TEST_CASE(FaceLocalControlOptions)
34{
35 ControlParameters parameters;
36 parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
37
38 Block wire = parameters.wireEncode();
39
40 ControlParameters decoded(wire);
41 BOOST_CHECK_EQUAL(decoded.getLocalControlFeature(), LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
42 BOOST_CHECK_EQUAL(decoded.hasName(), false);
43 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
44 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
45 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
46 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
47}
48
49BOOST_AUTO_TEST_CASE(FibOptions)
50{
51 ControlParameters parameters;
52 parameters.setName("ndn:/example")
53 .setFaceId(4)
54 .setCost(555);
55
56 Block wire = parameters.wireEncode();
57
58 ControlParameters decoded(wire);
59 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example"));
60 BOOST_CHECK_EQUAL(decoded.getFaceId(), 4);
61 BOOST_CHECK_EQUAL(decoded.getCost(), 555);
62 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
63 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
64 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
65}
66
67BOOST_AUTO_TEST_CASE(StrategyChoiceOptions)
68{
69 ControlParameters parameters;
70 parameters.setName("ndn:/")
71 .setStrategy("ndn:/strategy/A");
72
73 Block wire = parameters.wireEncode();
74
75 ControlParameters decoded(wire);
76 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/"));
77 BOOST_CHECK_EQUAL(decoded.getStrategy(), Name("ndn:/strategy/A"));
78 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
79 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
80 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
81 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
82}
83
84BOOST_AUTO_TEST_SUITE_END()
85
86} // namespace nfd
87} // namespace ndn