blob: c88a9b4fb073bfbad8b2f719c2436e53ce89a564 [file] [log] [blame]
Alexander Afanasyev4671bf72014-05-19 09:01:37 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
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.
11 */
12
13#include "management/nfd-strategy-choice.hpp"
14
15#include "boost-test.hpp"
16
17namespace ndn {
18namespace nfd {
19namespace tests {
20
21BOOST_AUTO_TEST_SUITE(ManagementTestNfdStrategyChoice)
22
23BOOST_AUTO_TEST_CASE(Encode)
24{
25 StrategyChoice strategyChoice1;
26 strategyChoice1
27 .setName("/hello/world")
28 .setStrategy("/some/non/existing/strategy/name")
29 ;
30
31 Block wire;
32 BOOST_REQUIRE_NO_THROW(wire = strategyChoice1.wireEncode());
33
34 // These octets are obtained by the snippet below.
35 // This check is intended to detect unexpected encoding change in the future.
36 // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
37 // printf("0x%02x, ", *it);
38 // }
39 static const uint8_t expected[] = {
40 0x80, 0x39, 0x07, 0x0e, 0x08, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x08, 0x05, 0x77,
41 0x6f, 0x72, 0x6c, 0x64, 0x6b, 0x27, 0x07, 0x25, 0x08, 0x04, 0x73, 0x6f, 0x6d, 0x65,
42 0x08, 0x03, 0x6e, 0x6f, 0x6e, 0x08, 0x08, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e,
43 0x67, 0x08, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x08, 0x04, 0x6e,
44 0x61, 0x6d, 0x65
45 };
46 BOOST_REQUIRE_EQUAL_COLLECTIONS(expected, expected + sizeof(expected),
47 wire.begin(), wire.end());
48
49 BOOST_REQUIRE_NO_THROW(StrategyChoice(wire));
50 StrategyChoice strategyChoice2(wire);
51 BOOST_CHECK_EQUAL(strategyChoice1.getName(), strategyChoice2.getName());
52 BOOST_CHECK_EQUAL(strategyChoice1.getStrategy(), strategyChoice2.getStrategy());
53}
54
55BOOST_AUTO_TEST_SUITE_END()
56
57} // namespace tests
58} // namespace nfd
59} // namespace ndn