blob: 40fdfc372d1cd7943313b19cfdb637d0d19b5033 [file] [log] [blame]
Shock Jiang01712f32014-10-01 14:34:16 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyevfde570c2016-12-19 16:02:55 -08003 * Copyright (c) 2014-2016, Regents of the University of California.
Shock Jiang01712f32014-10-01 14:34:16 -07004 *
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 "clients/query.hpp"
21
Alexander Afanasyevfde570c2016-12-19 16:02:55 -080022#include "test-common.hpp"
Shock Jiang01712f32014-10-01 14:34:16 -070023
24namespace ndn {
25namespace ndns {
26namespace tests {
27
28BOOST_AUTO_TEST_SUITE(Query)
29
30BOOST_AUTO_TEST_CASE(TestCase)
31{
32 Name zone("/net");
33 name::Component qType = ndns::label::NDNS_ITERATIVE_QUERY;
34 Name hint;
35 ndns::Query q(hint, zone, qType);
36
37 q.setRrLabel(Name("/ndnsim/www"));
38 BOOST_CHECK_EQUAL(q.getRrLabel(), Name("ndnsim/www"));
39 BOOST_CHECK_EQUAL(q.getRrLabel(), Name("/ndnsim/www"));
40 BOOST_CHECK_EQUAL(q.getHint(), hint);
41 BOOST_CHECK_EQUAL(q.getZone(), zone);
42 BOOST_CHECK_EQUAL(q.getQueryType(), qType);
43
44 q.setRrType(ndns::label::CERT_RR_TYPE);
45 BOOST_CHECK_EQUAL(q.getRrType(), label::CERT_RR_TYPE);
46
47 Interest interest = q.toInterest();
48
49 ndns::Query q2(hint, zone, qType);
50 BOOST_CHECK_EQUAL(q2.fromInterest(hint, zone, interest), true);
51
52 ndns::Query q3;
53 BOOST_CHECK_EQUAL(q3.fromInterest(hint, zone, interest), true);
54
55 BOOST_CHECK_EQUAL(q, q3);
56 BOOST_CHECK_EQUAL(q, q2);
57
58 hint = Name("att");
59 ndns::Query q4(hint, zone, qType);
60 q4.setRrLabel("/ndnsim/www");
61 q4.setRrType(ndns::label::TXT_RR_TYPE);
62 interest = q4.toInterest();
63 ndns::Query q5;
64
65 BOOST_CHECK_EQUAL(q5.fromInterest(hint, zone, interest), true);
66 BOOST_CHECK_EQUAL(q4, q5);
67 BOOST_CHECK_NE(q2, q4);
68 }
69
70BOOST_AUTO_TEST_SUITE_END()
71
Alexander Afanasyevfde570c2016-12-19 16:02:55 -080072} // namespace tests
73} // namespace ndns
Shock Jiang01712f32014-10-01 14:34:16 -070074} // namespace ndn