blob: a7add12661a0c80e70034fb25c14813ae1b5de76 [file] [log] [blame]
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "management/nfd-control-response.hpp"
8
9#include "boost-test.hpp"
10
11namespace ndn {
12namespace nfd {
13
14BOOST_AUTO_TEST_SUITE(ManagementTestNfdControlResponse)
15
16const uint8_t TestControlResponse[] = {0x65, 0x17,
17 0x66, 0x02, 0x01, 0x94, 0x67, 0x11, 0x4e, 0x6f, 0x74,
18 0x68, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x6f, 0x74, 0x20,
19 0x66, 0x6f, 0x75, 0x6e, 0x64};
20
21// ControlResponse
22
23BOOST_AUTO_TEST_CASE(ControlResponseEncode)
24{
25 ControlResponse controlResponse(404, "Nothing not found");
26 const Block &wire = controlResponse.wireEncode();
27
28 BOOST_REQUIRE_EQUAL_COLLECTIONS(TestControlResponse, TestControlResponse+sizeof(TestControlResponse),
29 wire.begin(), wire.end());
30}
31
32BOOST_AUTO_TEST_CASE(ControlResponseDecode)
33{
34 ControlResponse controlResponse;
35
36 BOOST_REQUIRE_NO_THROW(controlResponse.wireDecode(Block(TestControlResponse, sizeof(TestControlResponse))));
37
38 BOOST_REQUIRE_EQUAL(controlResponse.getCode(), 404);
39 BOOST_REQUIRE_EQUAL(controlResponse.getText(), "Nothing not found");
40}
41
42BOOST_AUTO_TEST_SUITE_END()
43
44} // namespace nfd
45} // namespace ndn