Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2014 Regents of the University of Memphis. |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #include "lsdb.hpp" |
| 7 | #include "nlsr.hpp" |
| 8 | #include "lsa.hpp" |
| 9 | #include "name-prefix-list.hpp" |
| 10 | #include <boost/test/unit_test.hpp> |
| 11 | |
| 12 | namespace nlsr { |
| 13 | |
| 14 | namespace test { |
| 15 | |
| 16 | BOOST_AUTO_TEST_SUITE(TestLsdb) |
| 17 | |
| 18 | BOOST_AUTO_TEST_CASE(LsdbRemoveAndExists) |
| 19 | { |
| 20 | Nlsr nlsr1; |
| 21 | |
| 22 | NamePrefixList npl1; |
| 23 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 24 | std::string s1 = "name1"; |
| 25 | std::string s2 = "name2"; |
| 26 | std::string router1 = "router1/1"; |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 27 | |
| 28 | npl1.insert(s1); |
| 29 | npl1.insert(s2); |
| 30 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 31 | //For NameLsa lsType is name. |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 32 | //12 is seqNo, randomly generated. |
| 33 | //1800 is the default life time. |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 34 | NameLsa nlsa1("router1", std::string("name"), 12, 1800, npl1); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 35 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 36 | Lsdb lsdb1(nlsr1); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 37 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 38 | lsdb1.installNameLsa(nlsa1); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 39 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 40 | BOOST_CHECK(lsdb1.doesLsaExist("router1/1", std::string("name"))); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 41 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 42 | lsdb1.removeNameLsa(router1); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 43 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 44 | BOOST_CHECK_EQUAL(lsdb1.doesLsaExist("router1/1", std::string("name")), false); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | BOOST_AUTO_TEST_SUITE_END() |
| 48 | |
| 49 | } //namespace test |
| 50 | } //namespace nlsr |