Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "table/measurements.hpp" |
| 8 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 9 | #include "tests/test-common.hpp" |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 10 | |
| 11 | namespace nfd { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 12 | namespace tests { |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 13 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 14 | BOOST_FIXTURE_TEST_SUITE(TableMeasurements, BaseFixture) |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 15 | |
| 16 | BOOST_AUTO_TEST_CASE(Get_Parent) |
| 17 | { |
HangZhang | c85a23c | 2014-03-01 15:55:55 +0800 | [diff] [blame] | 18 | NameTree nameTree(1024); |
| 19 | Measurements measurements(nameTree); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 20 | |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 21 | Name name0; |
| 22 | Name nameA ("ndn:/A"); |
| 23 | Name nameAB("ndn:/A/B"); |
| 24 | |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 25 | shared_ptr<measurements::Entry> entryAB = measurements.get(nameAB); |
| 26 | BOOST_REQUIRE(static_cast<bool>(entryAB)); |
| 27 | BOOST_CHECK_EQUAL(entryAB->getName(), nameAB); |
| 28 | |
| 29 | shared_ptr<measurements::Entry> entry0 = measurements.get(name0); |
| 30 | BOOST_REQUIRE(static_cast<bool>(entry0)); |
| 31 | |
| 32 | shared_ptr<measurements::Entry> entryA = measurements.getParent(entryAB); |
| 33 | BOOST_REQUIRE(static_cast<bool>(entryA)); |
| 34 | BOOST_CHECK_EQUAL(entryA->getName(), nameA); |
| 35 | |
| 36 | shared_ptr<measurements::Entry> entry0c = measurements.getParent(entryA); |
| 37 | BOOST_CHECK_EQUAL(entry0, entry0c); |
| 38 | } |
| 39 | |
| 40 | BOOST_AUTO_TEST_SUITE_END() |
| 41 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 42 | } // namespace tests |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 43 | } // namespace nfd |