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 | { |
| 17 | Name name0; |
| 18 | Name nameA ("ndn:/A"); |
| 19 | Name nameAB("ndn:/A/B"); |
| 20 | |
| 21 | boost::asio::io_service ioService; |
| 22 | Measurements measurements(ioService); |
| 23 | |
| 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 |