blob: e39f8ddcdab5d8ab841b0de2a78b08e143d4b10f [file] [log] [blame]
Junxiao Shi899277a2017-07-07 22:12:12 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013-2017 Regents of the University of California.
4 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 */
21
22#include "interest-filter.hpp"
23#include "data.hpp"
24#include "security/signature-sha256-with-rsa.hpp"
25#include "security/digest-sha256.hpp"
26#include "encoding/buffer-stream.hpp"
27
28#include "boost-test.hpp"
29#include "identity-management-fixture.hpp"
30
31namespace ndn {
32namespace tests {
33
34BOOST_AUTO_TEST_SUITE(TestInterestFilter)
35
36BOOST_AUTO_TEST_CASE(Matching)
37{
38 BOOST_CHECK_EQUAL(InterestFilter("/a").doesMatch("/a/b"), true);
39 BOOST_CHECK_EQUAL(InterestFilter("/a/b").doesMatch("/a/b"), true);
40 BOOST_CHECK_EQUAL(InterestFilter("/a/b/c").doesMatch("/a/b"), false);
41
42 BOOST_CHECK_EQUAL(InterestFilter("/a", "<b>").doesMatch("/a/b"), true);
43 BOOST_CHECK_EQUAL(InterestFilter("/a/b", "<b>").doesMatch("/a/b"), false);
44
45 BOOST_CHECK_EQUAL(InterestFilter("/a/b", "<b>").doesMatch("/a/b/c/b"), false);
46 BOOST_CHECK_EQUAL(InterestFilter("/a/b", "<>*<b>").doesMatch("/a/b/c/b"), true);
47
48 BOOST_CHECK_EQUAL(InterestFilter("/a", "<b>").doesMatch("/a/b/c/d"), false);
49 BOOST_CHECK_EQUAL(InterestFilter("/a", "<b><>*").doesMatch("/a/b/c/d"), true);
50 BOOST_CHECK_EQUAL(InterestFilter("/a", "<b><>*").doesMatch("/a/b"), true);
51 BOOST_CHECK_EQUAL(InterestFilter("/a", "<b><>+").doesMatch("/a/b"), false);
52 BOOST_CHECK_EQUAL(InterestFilter("/a", "<b><>+").doesMatch("/a/b/c"), true);
53}
54
55BOOST_AUTO_TEST_SUITE_END() // TestInterestFilter
56
57} // namespace tests
58} // namespace ndn