blob: b5b915b50409dab8afcb413a1c364270a32a5e70 [file] [log] [blame]
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014, Regents of the University of California.
4 *
5 * This file is part of NDNS (Named Data Networking Domain Name Service).
6 * See AUTHORS.md for complete list of NDNS authors and contributors.
7 *
8 * NDNS is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "rr.hpp"
shockjianga5ae48c2014-07-27 23:21:41 -070021#include "boost-test.hpp"
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070022
shockjianga5ae48c2014-07-27 23:21:41 -070023//#include <boost/test/test_tools.hpp>
24//#include <string>
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070025
26namespace ndn {
27namespace ndns {
28namespace tests {
29
shockjianga5ae48c2014-07-27 23:21:41 -070030using namespace std;
31
32BOOST_AUTO_TEST_SUITE(rr)
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070033
34BOOST_AUTO_TEST_CASE(Encode)
35{
shockjianga5ae48c2014-07-27 23:21:41 -070036 string label = "rr:Encode";
37 printbegin(label);
38 RR rr;
39 std::string ex = "www2.ex.com";
40 uint32_t id = 201;
41 rr.setRrdata(ex);
42 rr.setId(id);
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070043
shockjianga5ae48c2014-07-27 23:21:41 -070044 cout<<"before encode"<<endl;
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070045 ndn::Block block = rr.wireEncode();
shockjianga5ae48c2014-07-27 23:21:41 -070046 cout<<"Encode finishes with totalLenght="<<block.size()<<endl;
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070047
shockjianga5ae48c2014-07-27 23:21:41 -070048
49
50 RR rr2;
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070051 rr2.wireDecode(block);
52
shockjianga5ae48c2014-07-27 23:21:41 -070053 BOOST_CHECK_EQUAL(rr2.getRrdata(), ex);
54 BOOST_CHECK_EQUAL(rr2.getId(), id);
55 printend(label);
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070056}
57
58BOOST_AUTO_TEST_SUITE_END()
59
60} // namespace tests
61} // namespace ndns
62} // namespace ndn