blob: 32e7e42f9561ac37caad2c4879c5e486e350f612 [file] [log] [blame]
Eric Newberryc3a46792017-09-24 14:54:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
Davide Pesavento47ce2ee2023-05-09 01:33:33 -04003 * Copyright (c) 2013-2023 Regents of the University of California.
Eric Newberryc3a46792017-09-24 14:54:24 -07004 *
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/packet-base.hpp"
Davide Pesavento7e780642018-11-24 15:51:34 -050023#include "ndn-cxx/interest.hpp"
24#include "ndn-cxx/lp/tags.hpp"
Eric Newberryc3a46792017-09-24 14:54:24 -070025
Davide Pesavento7e780642018-11-24 15:51:34 -050026#include "tests/boost-test.hpp"
Eric Newberryc3a46792017-09-24 14:54:24 -070027
Davide Pesavento47ce2ee2023-05-09 01:33:33 -040028namespace ndn::tests {
Eric Newberryc3a46792017-09-24 14:54:24 -070029
Junxiao Shi1e36ceb2018-12-17 13:20:26 -070030BOOST_AUTO_TEST_SUITE(Detail)
Eric Newberryc3a46792017-09-24 14:54:24 -070031BOOST_AUTO_TEST_SUITE(TestPacketBase)
32
33BOOST_AUTO_TEST_CASE(CongestionMark)
34{
35 Interest interest;
36
37 BOOST_CHECK_EQUAL(interest.getCongestionMark(), 0);
38
39 auto tag = interest.getTag<lp::CongestionMarkTag>();
40 BOOST_CHECK(!tag);
41
42 interest.setCongestionMark(true);
43 tag = interest.getTag<lp::CongestionMarkTag>();
44 BOOST_REQUIRE(tag);
45 BOOST_CHECK_EQUAL(*tag, 1);
46
47 interest.setCongestionMark(false);
48 tag = interest.getTag<lp::CongestionMarkTag>();
49 BOOST_CHECK(!tag);
50
51 interest.setCongestionMark(300);
52 tag = interest.getTag<lp::CongestionMarkTag>();
53 BOOST_REQUIRE(tag);
54 BOOST_CHECK_EQUAL(*tag, 300);
55
56 interest.setCongestionMark(0);
57 tag = interest.getTag<lp::CongestionMarkTag>();
58 BOOST_CHECK(!tag);
59}
60
61BOOST_AUTO_TEST_SUITE_END() // TestPacketBase
Junxiao Shi1e36ceb2018-12-17 13:20:26 -070062BOOST_AUTO_TEST_SUITE_END() // Detail
Eric Newberryc3a46792017-09-24 14:54:24 -070063
Davide Pesavento47ce2ee2023-05-09 01:33:33 -040064} // namespace ndn::tests