blob: 9ce5dcb105d606b56081441bb9dbe0c1db3a87f5 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -07002/**
Spyridon Mastorakis429634f2015-02-19 17:35:33 -08003 * Copyright (c) 2013-2015 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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 Afanasyevd1b5c412014-03-27 15:03:51 -070020 */
21
22#include "management/nfd-control-response.hpp"
23
24#include "boost-test.hpp"
25
26namespace ndn {
27namespace nfd {
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080028namespace tests {
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070029
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080030BOOST_AUTO_TEST_SUITE(ManagementNfdControlResponse)
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070031
32const uint8_t TestControlResponse[] = {0x65, 0x17,
33 0x66, 0x02, 0x01, 0x94, 0x67, 0x11, 0x4e, 0x6f, 0x74,
34 0x68, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x6f, 0x74, 0x20,
35 0x66, 0x6f, 0x75, 0x6e, 0x64};
36
37// ControlResponse
38
39BOOST_AUTO_TEST_CASE(ControlResponseEncode)
40{
41 ControlResponse controlResponse(404, "Nothing not found");
42 const Block &wire = controlResponse.wireEncode();
43
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070044 BOOST_REQUIRE_EQUAL_COLLECTIONS(TestControlResponse,
45 TestControlResponse+sizeof(TestControlResponse),
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070046 wire.begin(), wire.end());
47}
48
49BOOST_AUTO_TEST_CASE(ControlResponseDecode)
50{
51 ControlResponse controlResponse;
52
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070053 BOOST_REQUIRE_NO_THROW(controlResponse.wireDecode(Block(TestControlResponse,
54 sizeof(TestControlResponse))));
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070055
56 BOOST_REQUIRE_EQUAL(controlResponse.getCode(), 404);
57 BOOST_REQUIRE_EQUAL(controlResponse.getText(), "Nothing not found");
58}
59
60BOOST_AUTO_TEST_SUITE_END()
61
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080062} // namespace tests
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070063} // namespace nfd
64} // namespace ndn