Junxiao Shi | 688a641 | 2017-06-22 10:12:07 +0000 | [diff] [blame] | 1 | /* -*- 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 "delegation.hpp" |
| 23 | |
| 24 | #include "boost-test.hpp" |
| 25 | #include <boost/lexical_cast.hpp> |
| 26 | |
| 27 | namespace ndn { |
| 28 | namespace tests { |
| 29 | |
| 30 | BOOST_AUTO_TEST_SUITE(TestDelegation) |
| 31 | |
| 32 | BOOST_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 | |
| 56 | BOOST_AUTO_TEST_CASE(Print) |
| 57 | { |
| 58 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(Delegation{1, "/B"}), "/B(1)"); |
| 59 | } |
| 60 | |
| 61 | BOOST_AUTO_TEST_SUITE_END() // TestDelegation |
| 62 | |
| 63 | } // namespace tests |
| 64 | } // namespace ndn |