blob: 72caa7e8361f01ba22f7881734537a7673550b6e [file] [log] [blame]
Alexander Afanasyeva3887ae2014-12-29 16:11:57 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento3b101d02018-07-21 22:44:09 -04002/*
3 * Copyright (c) 2013-2018 Regents of the University of California.
Alexander Afanasyeva3887ae2014-12-29 16:11:57 -08004 *
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
Junxiao Shi1e36ceb2018-12-17 13:20:26 -070022#include "ndn-cxx/detail/tag-host.hpp"
Davide Pesavento7e780642018-11-24 15:51:34 -050023#include "ndn-cxx/data.hpp"
24#include "ndn-cxx/interest.hpp"
Alexander Afanasyeva3887ae2014-12-29 16:11:57 -080025
Davide Pesavento7e780642018-11-24 15:51:34 -050026#include "tests/boost-test.hpp"
Alexander Afanasyeva3887ae2014-12-29 16:11:57 -080027
28#include <boost/mpl/vector.hpp>
29
30namespace ndn {
31namespace tests {
32
Junxiao Shi1e36ceb2018-12-17 13:20:26 -070033BOOST_AUTO_TEST_SUITE(Detail)
Alexander Afanasyeva3887ae2014-12-29 16:11:57 -080034BOOST_AUTO_TEST_SUITE(TestTagHost)
35
36class TestTag : public Tag
37{
38public:
Davide Pesavento3b101d02018-07-21 22:44:09 -040039 static constexpr int
40 getTypeId() noexcept
Alexander Afanasyeva3887ae2014-12-29 16:11:57 -080041 {
42 return 1;
43 }
44};
45
46class TestTag2 : public Tag
47{
48public:
Davide Pesavento3b101d02018-07-21 22:44:09 -040049 static constexpr int
50 getTypeId() noexcept
Alexander Afanasyeva3887ae2014-12-29 16:11:57 -080051 {
52 return 2;
53 }
54};
55
56typedef boost::mpl::vector<TagHost, Interest, Data> Fixtures;
57
58BOOST_FIXTURE_TEST_CASE_TEMPLATE(Basic, T, Fixtures, T)
59{
60 BOOST_CHECK(this->template getTag<TestTag>() == nullptr);
61 BOOST_CHECK(this->template getTag<TestTag2>() == nullptr);
62
63 this->setTag(make_shared<TestTag>());
64
65 BOOST_CHECK(this->template getTag<TestTag>() != nullptr);
66 BOOST_CHECK(this->template getTag<TestTag2>() == nullptr);
67
68 this->setTag(make_shared<TestTag2>());
69
70 BOOST_CHECK(this->template getTag<TestTag>() != nullptr);
71 BOOST_CHECK(this->template getTag<TestTag2>() != nullptr);
72
73 this->template removeTag<TestTag2>();
74
75 BOOST_CHECK(this->template getTag<TestTag>() != nullptr);
76 BOOST_CHECK(this->template getTag<TestTag2>() == nullptr);
77
78 this->template removeTag<TestTag>();
79
80 BOOST_CHECK(this->template getTag<TestTag>() == nullptr);
81 BOOST_CHECK(this->template getTag<TestTag2>() == nullptr);
82}
83
Davide Pesaventoeee3e822016-11-26 19:19:34 +010084BOOST_AUTO_TEST_SUITE_END() // TestTagHost
Junxiao Shi1e36ceb2018-12-17 13:20:26 -070085BOOST_AUTO_TEST_SUITE_END() // Detail
Alexander Afanasyeva3887ae2014-12-29 16:11:57 -080086
87} // namespace tests
88} // namespace ndn