Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014 Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology |
| 9 | * |
| 10 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 11 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 12 | * |
| 13 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 14 | * of the GNU General Public License as published by the Free Software Foundation, |
| 15 | * either version 3 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 18 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 19 | * PURPOSE. See the GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along with |
| 22 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 23 | **/ |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 24 | |
| 25 | #include "table/measurements.hpp" |
| 26 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 27 | #include "tests/test-common.hpp" |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 28 | |
| 29 | namespace nfd { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 30 | namespace tests { |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 31 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 32 | BOOST_FIXTURE_TEST_SUITE(TableMeasurements, BaseFixture) |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 33 | |
| 34 | BOOST_AUTO_TEST_CASE(Get_Parent) |
| 35 | { |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame^] | 36 | NameTree nameTree; |
HangZhang | c85a23c | 2014-03-01 15:55:55 +0800 | [diff] [blame] | 37 | Measurements measurements(nameTree); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 38 | |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 39 | Name name0; |
| 40 | Name nameA ("ndn:/A"); |
| 41 | Name nameAB("ndn:/A/B"); |
| 42 | |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 43 | shared_ptr<measurements::Entry> entryAB = measurements.get(nameAB); |
| 44 | BOOST_REQUIRE(static_cast<bool>(entryAB)); |
| 45 | BOOST_CHECK_EQUAL(entryAB->getName(), nameAB); |
| 46 | |
| 47 | shared_ptr<measurements::Entry> entry0 = measurements.get(name0); |
| 48 | BOOST_REQUIRE(static_cast<bool>(entry0)); |
| 49 | |
| 50 | shared_ptr<measurements::Entry> entryA = measurements.getParent(entryAB); |
| 51 | BOOST_REQUIRE(static_cast<bool>(entryA)); |
| 52 | BOOST_CHECK_EQUAL(entryA->getName(), nameA); |
| 53 | |
| 54 | shared_ptr<measurements::Entry> entry0c = measurements.getParent(entryA); |
| 55 | BOOST_CHECK_EQUAL(entry0, entry0c); |
| 56 | } |
| 57 | |
| 58 | BOOST_AUTO_TEST_SUITE_END() |
| 59 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 60 | } // namespace tests |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 61 | } // namespace nfd |