Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 1 | /* -*- 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" |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame^] | 21 | #include "boost-test.hpp" |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 22 | |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame^] | 23 | //#include <boost/test/test_tools.hpp> |
| 24 | //#include <string> |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 25 | |
| 26 | namespace ndn { |
| 27 | namespace ndns { |
| 28 | namespace tests { |
| 29 | |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame^] | 30 | using namespace std; |
| 31 | |
| 32 | BOOST_AUTO_TEST_SUITE(rr) |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 33 | |
| 34 | BOOST_AUTO_TEST_CASE(Encode) |
| 35 | { |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame^] | 36 | 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 Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 43 | |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame^] | 44 | cout<<"before encode"<<endl; |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 45 | ndn::Block block = rr.wireEncode(); |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame^] | 46 | cout<<"Encode finishes with totalLenght="<<block.size()<<endl; |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 47 | |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame^] | 48 | |
| 49 | |
| 50 | RR rr2; |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 51 | rr2.wireDecode(block); |
| 52 | |
shockjiang | a5ae48c | 2014-07-27 23:21:41 -0700 | [diff] [blame^] | 53 | BOOST_CHECK_EQUAL(rr2.getRrdata(), ex); |
| 54 | BOOST_CHECK_EQUAL(rr2.getId(), id); |
| 55 | printend(label); |
Alexander Afanasyev | 6e3d1ac | 2014-07-21 12:47:49 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | BOOST_AUTO_TEST_SUITE_END() |
| 59 | |
| 60 | } // namespace tests |
| 61 | } // namespace ndns |
| 62 | } // namespace ndn |