Alexander Afanasyev | eaf105c | 2014-01-30 17:40:24 -0800 | [diff] [blame^] | 1 | /** |
| 2 | * Copyright (C) 2013 Regents of the University of California. |
| 3 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include <boost/test/unit_test.hpp> |
| 8 | |
| 9 | #include "management/control-response.hpp" |
| 10 | |
| 11 | #include <boost/test/output_test_stream.hpp> |
| 12 | |
| 13 | using namespace std; |
| 14 | |
| 15 | namespace ndn { |
| 16 | |
| 17 | BOOST_AUTO_TEST_SUITE(TestNfdControl) |
| 18 | |
| 19 | const uint8_t TestControlResponse[] = {0x65, 0x17, 0x66, 0x02, 0x01, 0x94, 0x67, 0x11, 0x4e, 0x6f, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64}; |
| 20 | |
| 21 | BOOST_AUTO_TEST_CASE (ControlResponseEncode) |
| 22 | { |
| 23 | ndn::ControlResponse controlResponse(404, "Nothing not found"); |
| 24 | const Block &wire = controlResponse.wireEncode(); |
| 25 | |
| 26 | BOOST_REQUIRE_EQUAL_COLLECTIONS(TestControlResponse, TestControlResponse+sizeof(TestControlResponse), |
| 27 | wire.begin(), wire.end()); |
| 28 | } |
| 29 | |
| 30 | BOOST_AUTO_TEST_CASE (ControlResponseDecode) |
| 31 | { |
| 32 | ndn::ControlResponse controlResponse; |
| 33 | |
| 34 | BOOST_REQUIRE_NO_THROW(controlResponse.wireDecode(Block(TestControlResponse, sizeof(TestControlResponse)))); |
| 35 | |
| 36 | BOOST_REQUIRE_EQUAL(controlResponse.getCode(), 404); |
| 37 | BOOST_REQUIRE_EQUAL(controlResponse.getText(), "Nothing not found"); |
| 38 | } |
| 39 | |
| 40 | BOOST_AUTO_TEST_SUITE_END() |
| 41 | |
| 42 | } // namespace ndn |