Junxiao Shi | 5174232 | 2017-08-13 17:04:52 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
Davide Pesavento | 74daf74 | 2018-11-23 18:14:13 -0500 | [diff] [blame] | 3 | * Copyright (c) 2013-2018 Regents of the University of California. |
Junxiao Shi | 5174232 | 2017-08-13 17:04:52 +0000 | [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 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 22 | #include "ndn-cxx/mgmt/control-response.hpp" |
Junxiao Shi | 5174232 | 2017-08-13 17:04:52 +0000 | [diff] [blame] | 23 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 24 | #include "tests/boost-test.hpp" |
Junxiao Shi | 5174232 | 2017-08-13 17:04:52 +0000 | [diff] [blame] | 25 | |
| 26 | namespace ndn { |
| 27 | namespace mgmt { |
| 28 | namespace tests { |
| 29 | |
| 30 | BOOST_AUTO_TEST_SUITE(Mgmt) |
| 31 | BOOST_AUTO_TEST_SUITE(TestControlResponse) |
| 32 | |
| 33 | static const uint8_t WIRE[] = { |
| 34 | 0x65, 0x17, // ControlResponse |
| 35 | 0x66, 0x02, // StatusCode |
| 36 | 0x01, 0x94, |
| 37 | 0x67, 0x11, // StatusText |
| 38 | 0x4e, 0x6f, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x6f, 0x74, 0x20, |
| 39 | 0x66, 0x6f, 0x75, 0x6e, 0x64}; |
| 40 | |
| 41 | BOOST_AUTO_TEST_CASE(Encode) |
| 42 | { |
| 43 | ControlResponse cr(404, "Nothing not found"); |
| 44 | const Block& wire = cr.wireEncode(); |
| 45 | BOOST_CHECK_EQUAL_COLLECTIONS(WIRE, WIRE + sizeof(WIRE), |
| 46 | wire.begin(), wire.end()); |
| 47 | } |
| 48 | |
| 49 | BOOST_AUTO_TEST_CASE(Decode) |
| 50 | { |
| 51 | ControlResponse cr(Block(WIRE, sizeof(WIRE))); |
| 52 | BOOST_CHECK_EQUAL(cr.getCode(), 404); |
| 53 | BOOST_CHECK_EQUAL(cr.getText(), "Nothing not found"); |
| 54 | } |
| 55 | |
| 56 | BOOST_AUTO_TEST_SUITE_END() // TestControlResponse |
| 57 | BOOST_AUTO_TEST_SUITE_END() // Mgmt |
| 58 | |
| 59 | } // namespace tests |
| 60 | } // namespace mgmt |
| 61 | } // namespace ndn |