blob: 9f23e89b694b3bd983e13a23970c363268d6e6ee [file] [log] [blame]
Junxiao Shi688a6412017-06-22 10:12:07 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento74daf742018-11-23 18:14:13 -05002/*
3 * Copyright (c) 2013-2018 Regents of the University of California.
Junxiao Shi688a6412017-06-22 10:12:07 +00004 *
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
Davide Pesavento7e780642018-11-24 15:51:34 -050022#include "ndn-cxx/delegation.hpp"
Junxiao Shi688a6412017-06-22 10:12:07 +000023
Davide Pesavento7e780642018-11-24 15:51:34 -050024#include "tests/boost-test.hpp"
Junxiao Shi688a6412017-06-22 10:12:07 +000025#include <boost/lexical_cast.hpp>
26
27namespace ndn {
28namespace tests {
29
30BOOST_AUTO_TEST_SUITE(TestDelegation)
31
32BOOST_AUTO_TEST_CASE(Compare)
33{
34 BOOST_CHECK_EQUAL((Delegation{1, "/A"}), (Delegation{1, "/A"}));
35 BOOST_CHECK_LE((Delegation{1, "/A"}), (Delegation{1, "/A"}));
36 BOOST_CHECK_GE((Delegation{1, "/A"}), (Delegation{1, "/A"}));
37
38 BOOST_CHECK_NE((Delegation{1, "/A"}), (Delegation{2, "/A"}));
39 BOOST_CHECK_NE((Delegation{1, "/A"}), (Delegation{1, "/B"}));
40
41 BOOST_CHECK_LT((Delegation{1, "/A"}), (Delegation{1, "/B"}));
42 BOOST_CHECK_LE((Delegation{1, "/A"}), (Delegation{1, "/B"}));
43 BOOST_CHECK_LT((Delegation{1, "/B"}), (Delegation{2, "/A"}));
44 BOOST_CHECK_LE((Delegation{1, "/B"}), (Delegation{2, "/A"}));
45 BOOST_CHECK_LT((Delegation{1, "/A"}), (Delegation{2, "/A"}));
46 BOOST_CHECK_LE((Delegation{1, "/A"}), (Delegation{2, "/A"}));
47
48 BOOST_CHECK_GT((Delegation{1, "/B"}), (Delegation{1, "/A"}));
49 BOOST_CHECK_GE((Delegation{1, "/B"}), (Delegation{1, "/A"}));
50 BOOST_CHECK_GT((Delegation{2, "/A"}), (Delegation{1, "/B"}));
51 BOOST_CHECK_GE((Delegation{2, "/A"}), (Delegation{1, "/B"}));
52 BOOST_CHECK_GT((Delegation{2, "/A"}), (Delegation{1, "/A"}));
53 BOOST_CHECK_GE((Delegation{2, "/A"}), (Delegation{1, "/A"}));
54}
55
56BOOST_AUTO_TEST_CASE(Print)
57{
58 BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(Delegation{1, "/B"}), "/B(1)");
59}
60
61BOOST_AUTO_TEST_SUITE_END() // TestDelegation
62
63} // namespace tests
64} // namespace ndn