blob: aa2fe9bd5069ba7700caec168119ba851736c83a [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
shockjianga5ae48c2014-07-27 23:21:41 -070020#include "query.hpp"
21
22#include "boost-test.hpp"
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070023
24namespace ndn {
25namespace ndns {
26namespace tests {
27
shockjianga5ae48c2014-07-27 23:21:41 -070028using namespace std;
29
30BOOST_AUTO_TEST_SUITE(query)
31
32BOOST_AUTO_TEST_CASE(UnderstandInterest)
33{
34 printbegin("query::UnderstandInterst");
35 ndns::Query q;
36 Name n1("/dns.google.com");
37 Name n2("/www.baidu.com");
38 q.setAuthorityZone(n1);
39 q.setRrLabel(n2);
40 q.setQueryType(ndns::Query::QUERY_DNS_R);
41
42 Interest interest = q.toInterest();
43 cout<<"InterestName="<<interest.getName()<<endl;
44
45
46 ndns::Query q2;
47 Name name;
48 q2.fromInterest(name, interest);
49 cout<<"AuthZone="<<q2.getAuthorityZone()<<" RRLable="<<q2.getRrLabel()<<endl;
50 BOOST_CHECK_EQUAL(q.getAuthorityZone(), q2.getAuthorityZone());
51 BOOST_CHECK_EQUAL(q.getRrLabel(), q2.getRrLabel());
52 BOOST_CHECK_EQUAL(q.getQueryType(), q2.getQueryType());
53 printend("query:UnderstandInterst");
54}
55
56BOOST_AUTO_TEST_SUITE_END()
57
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070058} // namespace tests
59} // namespace ndns
60} // namespace ndn