blob: de980058602ab9abb35a0d3bdf7e21ba2d1163ed [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;
shockjiang99ad3892014-08-03 14:56:13 -070036 q.setFowardingHint(Name("/ucla"));
37
shockjianga5ae48c2014-07-27 23:21:41 -070038 Name n1("/dns.google.com");
39 Name n2("/www.baidu.com");
40 q.setAuthorityZone(n1);
41 q.setRrLabel(n2);
42 q.setQueryType(ndns::Query::QUERY_DNS_R);
43
44 Interest interest = q.toInterest();
45 cout<<"InterestName="<<interest.getName()<<endl;
46
47
48 ndns::Query q2;
49 Name name;
50 q2.fromInterest(name, interest);
51 cout<<"AuthZone="<<q2.getAuthorityZone()<<" RRLable="<<q2.getRrLabel()<<endl;
52 BOOST_CHECK_EQUAL(q.getAuthorityZone(), q2.getAuthorityZone());
53 BOOST_CHECK_EQUAL(q.getRrLabel(), q2.getRrLabel());
54 BOOST_CHECK_EQUAL(q.getQueryType(), q2.getQueryType());
shockjiang99ad3892014-08-03 14:56:13 -070055 BOOST_CHECK_EQUAL(q.getFowardingHint(), q2.getFowardingHint());
shockjianga5ae48c2014-07-27 23:21:41 -070056 printend("query:UnderstandInterst");
57}
58
59BOOST_AUTO_TEST_SUITE_END()
60
Alexander Afanasyev6e3d1ac2014-07-21 12:47:49 -070061} // namespace tests
62} // namespace ndns
63} // namespace ndn