Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 2 | /** |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 3 | * Copyright (c) 2013-2016 Regents of the University of California. |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 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. |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 20 | */ |
| 21 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 22 | #include "mgmt/nfd/strategy-choice.hpp" |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 23 | |
| 24 | #include "boost-test.hpp" |
| 25 | |
| 26 | namespace ndn { |
| 27 | namespace nfd { |
| 28 | namespace tests { |
| 29 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 30 | BOOST_AUTO_TEST_SUITE(Mgmt) |
| 31 | BOOST_AUTO_TEST_SUITE(Nfd) |
| 32 | BOOST_AUTO_TEST_SUITE(TestStrategyChoice) |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 33 | |
| 34 | BOOST_AUTO_TEST_CASE(Encode) |
| 35 | { |
| 36 | StrategyChoice strategyChoice1; |
| 37 | strategyChoice1 |
| 38 | .setName("/hello/world") |
| 39 | .setStrategy("/some/non/existing/strategy/name") |
| 40 | ; |
| 41 | |
| 42 | Block wire; |
| 43 | BOOST_REQUIRE_NO_THROW(wire = strategyChoice1.wireEncode()); |
| 44 | |
| 45 | // These octets are obtained by the snippet below. |
| 46 | // This check is intended to detect unexpected encoding change in the future. |
| 47 | // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) { |
| 48 | // printf("0x%02x, ", *it); |
| 49 | // } |
| 50 | static const uint8_t expected[] = { |
| 51 | 0x80, 0x39, 0x07, 0x0e, 0x08, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x08, 0x05, 0x77, |
| 52 | 0x6f, 0x72, 0x6c, 0x64, 0x6b, 0x27, 0x07, 0x25, 0x08, 0x04, 0x73, 0x6f, 0x6d, 0x65, |
| 53 | 0x08, 0x03, 0x6e, 0x6f, 0x6e, 0x08, 0x08, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, |
| 54 | 0x67, 0x08, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x08, 0x04, 0x6e, |
| 55 | 0x61, 0x6d, 0x65 |
| 56 | }; |
| 57 | BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected), |
| 58 | wire.begin(), wire.end()); |
| 59 | |
| 60 | BOOST_REQUIRE_NO_THROW(StrategyChoice(wire)); |
| 61 | StrategyChoice strategyChoice2(wire); |
| 62 | BOOST_CHECK_EQUAL(strategyChoice1.getName(), strategyChoice2.getName()); |
| 63 | BOOST_CHECK_EQUAL(strategyChoice1.getStrategy(), strategyChoice2.getStrategy()); |
| 64 | } |
| 65 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 66 | BOOST_AUTO_TEST_SUITE_END() // TestStrategyChoice |
| 67 | BOOST_AUTO_TEST_SUITE_END() // Nfd |
| 68 | BOOST_AUTO_TEST_SUITE_END() // Mgmt |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 69 | |
| 70 | } // namespace tests |
| 71 | } // namespace nfd |
| 72 | } // namespace ndn |