blob: 4cccc95b673e1d2ca8bdc59544e2d63d1ad617f0 [file] [log] [blame]
Junxiao Shi0eba1aa2014-10-25 09:54:08 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Spyridon Mastorakis429634f2015-02-19 17:35:33 -08003 * Copyright (c) 2013-2015 Regents of the University of California.
Junxiao Shi0eba1aa2014-10-25 09:54:08 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
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.
20 */
21
22#include "management/nfd-command-options.hpp"
Junxiao Shic6acc7a2015-06-23 10:03:56 -070023#include "security/signing-helpers.hpp"
24
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070025#include "boost-test.hpp"
26
27namespace ndn {
28namespace nfd {
29namespace tests {
30
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080031BOOST_AUTO_TEST_SUITE(ManagementNfdCommandOptions)
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070032
33BOOST_AUTO_TEST_CASE(Timeout)
34{
35 CommandOptions co;
36 BOOST_CHECK_EQUAL(co.getTimeout(), CommandOptions::DEFAULT_TIMEOUT);
37
38 co.setTimeout(time::milliseconds(7414));
39 BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(7414));
40
41 BOOST_CHECK_THROW(co.setTimeout(time::milliseconds::zero()), std::out_of_range);
42 BOOST_CHECK_THROW(co.setTimeout(time::milliseconds(-1)), std::out_of_range);
43 BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(7414)); // unchanged after throw
44
45 co.setTimeout(time::milliseconds(1));
46 BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(1));
47}
48
49BOOST_AUTO_TEST_CASE(Prefix)
50{
51 CommandOptions co;
52 BOOST_CHECK_EQUAL(co.getPrefix(), CommandOptions::DEFAULT_PREFIX);
53
54 co.setPrefix(Name()); // empty Name is okay
55 BOOST_CHECK_EQUAL(co.getPrefix(), Name());
56
57 co.setPrefix("ndn:/localhop/net/example/nfd");
58 BOOST_CHECK_EQUAL(co.getPrefix(), Name("ndn:/localhop/net/example/nfd"));
59}
60
Junxiao Shic6acc7a2015-06-23 10:03:56 -070061BOOST_AUTO_TEST_CASE(SigningInfo)
62{
63 CommandOptions co;
64 BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerType(), security::SigningInfo::SIGNER_TYPE_NULL);
65
66 co.setSigningInfo(signingByIdentity("ndn:/tmp/identity"));
67 BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerType(), security::SigningInfo::SIGNER_TYPE_ID);
68 BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerName(), "ndn:/tmp/identity");
69}
70
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070071BOOST_AUTO_TEST_SUITE_END()
72
73} // namespace tests
74} // namespace nfd
75} // namespace ndn