Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | b849f61 | 2018-04-01 23:52:54 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | 25d4f1c | 2020-04-29 23:31:04 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2020 Regents of the University of California. |
Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 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 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 22 | #include "ndn-cxx/util/backports.hpp" |
Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 23 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 24 | #include "tests/boost-test.hpp" |
| 25 | |
Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 26 | namespace ndn { |
| 27 | namespace tests { |
| 28 | |
| 29 | BOOST_AUTO_TEST_SUITE(Util) |
| 30 | BOOST_AUTO_TEST_SUITE(TestBackports) |
| 31 | |
Weiwei Liu | cfaa1ad | 2016-08-28 16:30:56 -0700 | [diff] [blame] | 32 | BOOST_AUTO_TEST_CASE(Clamp) |
| 33 | { |
| 34 | int x = clamp(5, 1, 10); |
| 35 | BOOST_CHECK_EQUAL(x, 5); |
| 36 | |
| 37 | x = clamp(-5, 1, 10); |
| 38 | BOOST_CHECK_EQUAL(x, 1); |
| 39 | |
| 40 | x = clamp(15, 1, 10); |
| 41 | BOOST_CHECK_EQUAL(x, 10); |
| 42 | |
| 43 | x = clamp(5, 10, 1, std::greater<int>()); |
| 44 | BOOST_CHECK_EQUAL(x, 5); |
| 45 | |
| 46 | x = clamp(-5, 10, 1, std::greater<int>()); |
| 47 | BOOST_CHECK_EQUAL(x, 1); |
| 48 | |
| 49 | x = clamp(15, 10, 1, std::greater<int>()); |
| 50 | BOOST_CHECK_EQUAL(x, 10); |
| 51 | } |
| 52 | |
Junxiao Shi | 1aecae2 | 2016-08-30 11:23:59 +0000 | [diff] [blame] | 53 | BOOST_AUTO_TEST_SUITE_END() // TestBackports |
| 54 | BOOST_AUTO_TEST_SUITE_END() // Util |
Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 55 | |
| 56 | } // namespace tests |
| 57 | } // namespace ndn |