Alexander Afanasyev | d1b5c41 | 2014-03-27 15:03:51 -0700 | [diff] [blame^] | 1 | /* -*- 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 | |
| 11 | namespace ndn { |
| 12 | namespace nfd { |
| 13 | |
| 14 | BOOST_AUTO_TEST_SUITE(ManagementTestNfdControlResponse) |
| 15 | |
| 16 | const 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 | |
| 23 | BOOST_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 | |
| 32 | BOOST_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 | |
| 42 | BOOST_AUTO_TEST_SUITE_END() |
| 43 | |
| 44 | } // namespace nfd |
| 45 | } // namespace ndn |