blob: d581ebc7ec55b064ea5e3f3dfcfd2bd9abcbf334 [file] [log] [blame]
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070011 */
12
13#include "management/nfd-control-response.hpp"
14
15#include "boost-test.hpp"
16
17namespace ndn {
18namespace nfd {
19
20BOOST_AUTO_TEST_SUITE(ManagementTestNfdControlResponse)
21
22const uint8_t TestControlResponse[] = {0x65, 0x17,
23 0x66, 0x02, 0x01, 0x94, 0x67, 0x11, 0x4e, 0x6f, 0x74,
24 0x68, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x6f, 0x74, 0x20,
25 0x66, 0x6f, 0x75, 0x6e, 0x64};
26
27// ControlResponse
28
29BOOST_AUTO_TEST_CASE(ControlResponseEncode)
30{
31 ControlResponse controlResponse(404, "Nothing not found");
32 const Block &wire = controlResponse.wireEncode();
33
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070034 BOOST_REQUIRE_EQUAL_COLLECTIONS(TestControlResponse,
35 TestControlResponse+sizeof(TestControlResponse),
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070036 wire.begin(), wire.end());
37}
38
39BOOST_AUTO_TEST_CASE(ControlResponseDecode)
40{
41 ControlResponse controlResponse;
42
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070043 BOOST_REQUIRE_NO_THROW(controlResponse.wireDecode(Block(TestControlResponse,
44 sizeof(TestControlResponse))));
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070045
46 BOOST_REQUIRE_EQUAL(controlResponse.getCode(), 404);
47 BOOST_REQUIRE_EQUAL(controlResponse.getText(), "Nothing not found");
48}
49
50BOOST_AUTO_TEST_SUITE_END()
51
52} // namespace nfd
53} // namespace ndn