Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | bdd88c1 | 2020-11-26 00:35:08 -0500 | [diff] [blame^] | 2 | /* |
| 3 | * Copyright (c) 2014-2020, Regents of the University of California. |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 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 "ndns-label.hpp" |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 21 | |
Davide Pesavento | bdd88c1 | 2020-11-26 00:35:08 -0500 | [diff] [blame^] | 22 | #include "boost-test.hpp" |
| 23 | |
| 24 | #include <ndn-cxx/data.hpp> |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 25 | |
| 26 | namespace ndn { |
| 27 | namespace ndns { |
| 28 | namespace tests { |
| 29 | |
| 30 | BOOST_AUTO_TEST_SUITE(NdnsLabel) |
| 31 | |
| 32 | BOOST_AUTO_TEST_CASE(MatchInterest) |
| 33 | { |
| 34 | using namespace label; |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 35 | Name zone("/net/ndnsim"); |
| 36 | |
Yumin Xia | 6343c5b | 2016-10-20 15:45:50 -0700 | [diff] [blame] | 37 | Interest interest1("/net/ndnsim/NDNS/www/dsk-111/NS"); |
| 38 | Interest interest2("/net/ndnsim/NDNS/www/dsk-111/NS/%FD%00"); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 39 | |
| 40 | MatchResult re; |
Yumin Xia | 6343c5b | 2016-10-20 15:45:50 -0700 | [diff] [blame] | 41 | BOOST_CHECK_EQUAL(matchName(interest1, zone, re), true); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 42 | BOOST_CHECK_EQUAL(re.rrLabel, Name("/www/dsk-111")); |
| 43 | BOOST_CHECK_EQUAL(re.rrType, name::Component("NS")); |
| 44 | BOOST_CHECK_EQUAL(re.version, name::Component()); |
| 45 | |
Yumin Xia | 6343c5b | 2016-10-20 15:45:50 -0700 | [diff] [blame] | 46 | BOOST_CHECK_EQUAL(matchName(interest2, zone, re), true); |
Alexander Afanasyev | aa46c27 | 2016-03-09 12:54:12 -0800 | [diff] [blame] | 47 | BOOST_CHECK_EQUAL(re.rrLabel, Name("/www/dsk-111")); |
| 48 | BOOST_CHECK_EQUAL(re.rrType, name::Component("NS")); |
| 49 | BOOST_CHECK_EQUAL(re.version, name::Component::fromEscapedString("%FD%00")); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | BOOST_AUTO_TEST_CASE(MatchData) |
| 53 | { |
| 54 | using namespace label; |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 55 | Name zone("/net/ndnsim"); |
| 56 | |
Yumin Xia | 6343c5b | 2016-10-20 15:45:50 -0700 | [diff] [blame] | 57 | Data data1("/net/ndnsim/NDNS/www/dsk-111/NS/%FD%00"); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 58 | |
| 59 | MatchResult re; |
Yumin Xia | 6343c5b | 2016-10-20 15:45:50 -0700 | [diff] [blame] | 60 | BOOST_CHECK_EQUAL(matchName(data1, zone, re), true); |
Shock Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 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 Jiang | 6cce21a | 2014-09-07 10:14:12 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | BOOST_AUTO_TEST_SUITE_END() |
| 68 | |
| 69 | } // namespace tests |
| 70 | } // namespace ndns |
| 71 | } // namespace ndn |