blob: a4e86d075bc8e4b1e30f48c82d4f27852e53d9d9 [file] [log] [blame]
Alexander Afanasyev52eb20d2014-02-06 18:25:54 -08001/**
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 "name.hpp"
10
11namespace ndn {
12
13BOOST_AUTO_TEST_SUITE(TestName)
14
15static const uint8_t TestName[] = {
16 0x3, 0x14, // Name
17 0x4, 0x5, // NameComponent
18 0x6c, 0x6f, 0x63, 0x61, 0x6c,
19 0x4, 0x3, // NameComponent
20 0x6e, 0x64, 0x6e,
21 0x4, 0x6, // NameComponent
22 0x70, 0x72, 0x65, 0x66, 0x69, 0x78
23};
24
25BOOST_AUTO_TEST_CASE (Encode)
26{
27 Name name("/local/ndn/prefix");
28
29 const Block &wire = name.wireEncode();
30
31 // for (Buffer::const_iterator i = wire.begin();
32 // i != wire.end();
33 // ++i)
34 // {
35 // std::ios::fmtflags saveFlags = std::cout.flags(std::ios::hex);
36
37 // if (i != wire.begin())
38 // std::cout << ", ";
39 // std::cout << "0x" << static_cast<uint32_t>(*i);
40
41 // std::cout.flags(saveFlags);
42 // }
43 // std::cout << std::endl;
44
45 BOOST_REQUIRE_EQUAL_COLLECTIONS(TestName, TestName+sizeof(TestName),
46 wire.begin(), wire.end());
47}
48
49
50BOOST_AUTO_TEST_CASE (Decode)
51{
52 Block block(TestName, sizeof(TestName));
53
54 Name name(block);
55
56 BOOST_CHECK_EQUAL(name.toUri(), "/local/ndn/prefix");
57}
58
59BOOST_AUTO_TEST_SUITE_END()
60
61} // namespace ndn