Alexander Afanasyev | d1b5c41 | 2014-03-27 15:03:51 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 3 | * 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 Afanasyev | d1b5c41 | 2014-03-27 15:03:51 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include "management/nfd-control-response.hpp" |
| 14 | |
| 15 | #include "boost-test.hpp" |
| 16 | |
| 17 | namespace ndn { |
| 18 | namespace nfd { |
| 19 | |
| 20 | BOOST_AUTO_TEST_SUITE(ManagementTestNfdControlResponse) |
| 21 | |
| 22 | const 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 | |
| 29 | BOOST_AUTO_TEST_CASE(ControlResponseEncode) |
| 30 | { |
| 31 | ControlResponse controlResponse(404, "Nothing not found"); |
| 32 | const Block &wire = controlResponse.wireEncode(); |
| 33 | |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 34 | BOOST_REQUIRE_EQUAL_COLLECTIONS(TestControlResponse, |
| 35 | TestControlResponse+sizeof(TestControlResponse), |
Alexander Afanasyev | d1b5c41 | 2014-03-27 15:03:51 -0700 | [diff] [blame] | 36 | wire.begin(), wire.end()); |
| 37 | } |
| 38 | |
| 39 | BOOST_AUTO_TEST_CASE(ControlResponseDecode) |
| 40 | { |
| 41 | ControlResponse controlResponse; |
| 42 | |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 43 | BOOST_REQUIRE_NO_THROW(controlResponse.wireDecode(Block(TestControlResponse, |
| 44 | sizeof(TestControlResponse)))); |
Alexander Afanasyev | d1b5c41 | 2014-03-27 15:03:51 -0700 | [diff] [blame] | 45 | |
| 46 | BOOST_REQUIRE_EQUAL(controlResponse.getCode(), 404); |
| 47 | BOOST_REQUIRE_EQUAL(controlResponse.getText(), "Nothing not found"); |
| 48 | } |
| 49 | |
| 50 | BOOST_AUTO_TEST_SUITE_END() |
| 51 | |
| 52 | } // namespace nfd |
| 53 | } // namespace ndn |