akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 2 | /** |
Muktadir R Chowdhury | 800833b | 2016-07-29 13:43:59 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, The University of Memphis, |
Vince Lehman | 6151e95 | 2015-02-16 12:36:00 -0600 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 6 | * |
| 7 | * This file is part of NLSR (Named-data Link State Routing). |
| 8 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | * |
| 10 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 11 | * of the GNU General Public License as published by the Free Software Foundation, |
| 12 | * either version 3 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE. See the GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 20 | **/ |
Vince Lehman | 6151e95 | 2015-02-16 12:36:00 -0600 | [diff] [blame] | 21 | |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 22 | #include "sequencing-manager.hpp" |
| 23 | #include <boost/test/unit_test.hpp> |
| 24 | |
| 25 | namespace nlsr { |
| 26 | |
| 27 | namespace test { |
| 28 | |
| 29 | BOOST_AUTO_TEST_SUITE(TestSequencingManager) |
| 30 | |
| 31 | BOOST_AUTO_TEST_CASE(SequencingManagerBasic) |
| 32 | { |
| 33 | SequencingManager sm1(120, 121, 122); |
| 34 | |
| 35 | SequencingManager sm2(sm1.getCombinedSeqNo()); |
| 36 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 37 | BOOST_CHECK_EQUAL(sm2.getNameLsaSeq(), (uint32_t)120); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 38 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 39 | BOOST_CHECK_EQUAL(sm2.getAdjLsaSeq(), (uint32_t)121); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 40 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 41 | BOOST_CHECK_EQUAL(sm2.getCorLsaSeq(), (uint32_t)122); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 42 | } |
| 43 | |
Vince Lehman | 6151e95 | 2015-02-16 12:36:00 -0600 | [diff] [blame] | 44 | BOOST_AUTO_TEST_CASE(BitMask) |
| 45 | { |
| 46 | uint64_t nameLsaSeqNoMax = 0xFFFFFF; |
| 47 | uint64_t corLsaSeqNoMax = 0xFFFFF; |
| 48 | uint64_t adjLsaSeqNoMax = 0xFFFFF; |
| 49 | |
| 50 | uint64_t seqNo = (nameLsaSeqNoMax << 40) | (corLsaSeqNoMax << 20) | adjLsaSeqNoMax; |
| 51 | SequencingManager manager(seqNo); |
| 52 | |
| 53 | BOOST_CHECK_EQUAL(manager.getNameLsaSeq(), nameLsaSeqNoMax); |
| 54 | BOOST_CHECK_EQUAL(manager.getCorLsaSeq(), corLsaSeqNoMax); |
| 55 | BOOST_CHECK_EQUAL(manager.getAdjLsaSeq(), adjLsaSeqNoMax); |
| 56 | } |
| 57 | |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 58 | BOOST_AUTO_TEST_SUITE_END() |
| 59 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame^] | 60 | } // namespace test |
| 61 | } // namespace nlsr |