blob: 186e7df2342b9fe2ccbdb2f26d969ebbdc89c0bd [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -05002/**
Nick Gordonfeae5572017-01-13 12:06:26 -06003 * Copyright (c) 2014-2017, The University of Memphis,
Vince Lehman6151e952015-02-16 12:36:00 -06004 * Regents of the University of California,
5 * Arizona Board of Regents.
akmhoque3d06e792014-05-27 16:23:20 -05006 *
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/>.
akmhoque3d06e792014-05-27 16:23:20 -050020 **/
Vince Lehman6151e952015-02-16 12:36:00 -060021
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050022#include "sequencing-manager.hpp"
23#include <boost/test/unit_test.hpp>
24
25namespace nlsr {
26
27namespace test {
28
29BOOST_AUTO_TEST_SUITE(TestSequencingManager)
30
31BOOST_AUTO_TEST_CASE(SequencingManagerBasic)
32{
33 SequencingManager sm1(120, 121, 122);
34
35 SequencingManager sm2(sm1.getCombinedSeqNo());
36
akmhoquefdbddb12014-05-02 18:35:19 -050037 BOOST_CHECK_EQUAL(sm2.getNameLsaSeq(), (uint32_t)120);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050038
akmhoquefdbddb12014-05-02 18:35:19 -050039 BOOST_CHECK_EQUAL(sm2.getAdjLsaSeq(), (uint32_t)121);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050040
akmhoquefdbddb12014-05-02 18:35:19 -050041 BOOST_CHECK_EQUAL(sm2.getCorLsaSeq(), (uint32_t)122);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050042}
43
Vince Lehman6151e952015-02-16 12:36:00 -060044BOOST_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 Gawandeeb582eb2014-05-01 14:25:20 -050058BOOST_AUTO_TEST_SUITE_END()
59
Nick Gordonfad8e252016-08-11 14:21:38 -050060} // namespace test
61} // namespace nlsr