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 | |
| 9 | #include <boost/test/unit_test.hpp> |
| 10 | |
| 11 | namespace nfd { |
| 12 | |
| 13 | BOOST_AUTO_TEST_SUITE(TableMeasurements) |
| 14 | |
| 15 | BOOST_AUTO_TEST_CASE(Get_Parent) |
| 16 | { |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame^] | 17 | resetGlobalIoService(); |
| 18 | Measurements measurements; |
| 19 | |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 20 | Name name0; |
| 21 | Name nameA ("ndn:/A"); |
| 22 | Name nameAB("ndn:/A/B"); |
| 23 | |
Junxiao Shi | 65d0072 | 2014-02-17 10:50:20 -0700 | [diff] [blame] | 24 | shared_ptr<measurements::Entry> entryAB = measurements.get(nameAB); |
| 25 | BOOST_REQUIRE(static_cast<bool>(entryAB)); |
| 26 | BOOST_CHECK_EQUAL(entryAB->getName(), nameAB); |
| 27 | |
| 28 | shared_ptr<measurements::Entry> entry0 = measurements.get(name0); |
| 29 | BOOST_REQUIRE(static_cast<bool>(entry0)); |
| 30 | |
| 31 | shared_ptr<measurements::Entry> entryA = measurements.getParent(entryAB); |
| 32 | BOOST_REQUIRE(static_cast<bool>(entryA)); |
| 33 | BOOST_CHECK_EQUAL(entryA->getName(), nameA); |
| 34 | |
| 35 | shared_ptr<measurements::Entry> entry0c = measurements.getParent(entryA); |
| 36 | BOOST_CHECK_EQUAL(entry0, entry0c); |
| 37 | } |
| 38 | |
| 39 | BOOST_AUTO_TEST_SUITE_END() |
| 40 | |
| 41 | } // namespace nfd |