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 "conf-file-processor.hpp" |
| 7 | #include "nlsr.hpp" |
| 8 | #include <boost/test/unit_test.hpp> |
| 9 | |
| 10 | namespace nlsr { |
| 11 | |
| 12 | namespace test { |
| 13 | |
| 14 | BOOST_AUTO_TEST_SUITE(TestConfFileProcessor) |
| 15 | |
| 16 | BOOST_AUTO_TEST_CASE(ConfFileProcessorSample) |
| 17 | { |
| 18 | Nlsr nlsr1; |
| 19 | |
| 20 | const std::string CONFIG = |
| 21 | "network ndn\n" |
| 22 | "site-name memphis.edu\n" |
| 23 | "router-name cs/macbook\n\n" |
| 24 | "ndnneighbor /ndn/memphis.edu/cs/maia 7\n" |
| 25 | "link-cost /ndn/memphis.edu/cs/maia 30\n" |
| 26 | "ndnneighbor /ndn/memphis.edu/cs/pollux 10\n" |
| 27 | "link-cost /ndn/memphis.edu/cs/pollux 25\n\n" |
| 28 | "ndnname /ndn/memphis.edu/cs/macbook/name1\n" |
| 29 | "ndnname /ndn/memphis.edu/cs/macbook/name2\n\n\n" |
| 30 | ; |
| 31 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 32 | std::ofstream config; |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 33 | config.open("unit-test-nlsr.conf"); |
| 34 | config << CONFIG; |
| 35 | config.close(); |
| 36 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame^] | 37 | const std::string CONFIG_FILE = "unit-test-nlsr.conf"; |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 38 | |
| 39 | ConfFileProcessor cfp1(nlsr1, CONFIG_FILE); |
| 40 | |
| 41 | cfp1.processConfFile(); |
| 42 | |
| 43 | BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/maia")); |
| 44 | BOOST_CHECK_EQUAL( |
| 45 | nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/maia").getName(), |
| 46 | "/ndn/memphis.edu/cs/maia"); |
| 47 | BOOST_CHECK_EQUAL( |
| 48 | nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/maia").getLinkCost(), |
| 49 | 30); |
| 50 | |
| 51 | BOOST_CHECK_EQUAL(nlsr1.getNamePrefixList().getSize(), 2); |
| 52 | |
| 53 | remove("unit-test-nlsr.conf"); |
| 54 | } |
| 55 | |
| 56 | BOOST_AUTO_TEST_SUITE_END() |
| 57 | |
| 58 | } //namespace test |
| 59 | } //namespace nlsr |