Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 3 | * Copyright (c) 2013-2016 Regents of the University of California. |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 4 | * |
| 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 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 22 | #include "mgmt/nfd/command-options.hpp" |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 23 | #include "security/signing-helpers.hpp" |
| 24 | |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 25 | #include "boost-test.hpp" |
| 26 | |
| 27 | namespace ndn { |
| 28 | namespace nfd { |
| 29 | namespace tests { |
| 30 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 31 | BOOST_AUTO_TEST_SUITE(Mgmt) |
| 32 | BOOST_AUTO_TEST_SUITE(Nfd) |
| 33 | BOOST_AUTO_TEST_SUITE(TestCommandOptions) |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 34 | |
| 35 | BOOST_AUTO_TEST_CASE(Timeout) |
| 36 | { |
| 37 | CommandOptions co; |
| 38 | BOOST_CHECK_EQUAL(co.getTimeout(), CommandOptions::DEFAULT_TIMEOUT); |
| 39 | |
| 40 | co.setTimeout(time::milliseconds(7414)); |
| 41 | BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(7414)); |
| 42 | |
| 43 | BOOST_CHECK_THROW(co.setTimeout(time::milliseconds::zero()), std::out_of_range); |
| 44 | BOOST_CHECK_THROW(co.setTimeout(time::milliseconds(-1)), std::out_of_range); |
| 45 | BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(7414)); // unchanged after throw |
| 46 | |
| 47 | co.setTimeout(time::milliseconds(1)); |
| 48 | BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(1)); |
| 49 | } |
| 50 | |
| 51 | BOOST_AUTO_TEST_CASE(Prefix) |
| 52 | { |
| 53 | CommandOptions co; |
| 54 | BOOST_CHECK_EQUAL(co.getPrefix(), CommandOptions::DEFAULT_PREFIX); |
| 55 | |
| 56 | co.setPrefix(Name()); // empty Name is okay |
| 57 | BOOST_CHECK_EQUAL(co.getPrefix(), Name()); |
| 58 | |
| 59 | co.setPrefix("ndn:/localhop/net/example/nfd"); |
| 60 | BOOST_CHECK_EQUAL(co.getPrefix(), Name("ndn:/localhop/net/example/nfd")); |
| 61 | } |
| 62 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 63 | BOOST_AUTO_TEST_CASE(SigningInfo) |
| 64 | { |
| 65 | CommandOptions co; |
| 66 | BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerType(), security::SigningInfo::SIGNER_TYPE_NULL); |
| 67 | |
| 68 | co.setSigningInfo(signingByIdentity("ndn:/tmp/identity")); |
| 69 | BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerType(), security::SigningInfo::SIGNER_TYPE_ID); |
| 70 | BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerName(), "ndn:/tmp/identity"); |
| 71 | } |
| 72 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 73 | BOOST_AUTO_TEST_SUITE_END() // TestCommandOptions |
| 74 | BOOST_AUTO_TEST_SUITE_END() // Nfd |
| 75 | BOOST_AUTO_TEST_SUITE_END() // Mgmt |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 76 | |
| 77 | } // namespace tests |
| 78 | } // namespace nfd |
| 79 | } // namespace ndn |