blob: 719d786a7300401e533eda62e132b78b3668eb17 [file] [log] [blame]
Shock Jiang6cce21a2014-09-07 10:14:12 -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 Jiang6cce21a2014-09-07 10:14:12 -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 "ndns-label.hpp"
Alexander Afanasyevfde570c2016-12-19 16:02:55 -080021
22#include "test-common.hpp"
Shock Jiang6cce21a2014-09-07 10:14:12 -070023
24namespace ndn {
25namespace ndns {
26namespace tests {
27
28BOOST_AUTO_TEST_SUITE(NdnsLabel)
29
30BOOST_AUTO_TEST_CASE(MatchInterest)
31{
32 using namespace label;
33 Name hint("/att");
34 Name zone("/net/ndnsim");
35
36 Interest interest1("/att/%F0./net/ndnsim/NDNS/www/dsk-111/NS");
37 Interest interest2("/att/%F0./net/ndnsim/NDNS/www/dsk-111/NS/%FD%00");
38
39 MatchResult re;
40 BOOST_CHECK_EQUAL(matchName(interest1, hint, zone, re), true);
41 BOOST_CHECK_EQUAL(re.rrLabel, Name("/www/dsk-111"));
42 BOOST_CHECK_EQUAL(re.rrType, name::Component("NS"));
43 BOOST_CHECK_EQUAL(re.version, name::Component());
44
45 BOOST_CHECK_EQUAL(matchName(interest2, hint, zone, re), true);
Alexander Afanasyevaa46c272016-03-09 12:54:12 -080046 BOOST_CHECK_EQUAL(re.rrLabel, Name("/www/dsk-111"));
47 BOOST_CHECK_EQUAL(re.rrType, name::Component("NS"));
48 BOOST_CHECK_EQUAL(re.version, name::Component::fromEscapedString("%FD%00"));
Shock Jiang6cce21a2014-09-07 10:14:12 -070049}
50
51BOOST_AUTO_TEST_CASE(MatchData)
52{
53 using namespace label;
54 Name hint("/att");
55 Name zone("/net/ndnsim");
56
57 Data data1("/att/%F0./net/ndnsim/NDNS/www/dsk-111/NS/%FD%00");
Shock Jiang6cce21a2014-09-07 10:14:12 -070058
59 MatchResult re;
60 BOOST_CHECK_EQUAL(matchName(data1, hint, zone, re), true);
61 BOOST_CHECK_EQUAL(re.rrLabel, Name("/www/dsk-111"));
62 BOOST_CHECK_EQUAL(re.rrType, name::Component("NS"));
63 BOOST_REQUIRE_NO_THROW(re.version.toVersion());
64 BOOST_CHECK_EQUAL(re.version.toVersion(), 0);
Shock Jiang6cce21a2014-09-07 10:14:12 -070065}
66
67BOOST_AUTO_TEST_SUITE_END()
68
69} // namespace tests
70} // namespace ndns
71} // namespace ndn