blob: fc9541550770f0295f1cfc1ea078fcf17a60f613 [file] [log] [blame]
Junxiao Shi65d00722014-02-17 10:50:20 -07001/* -*- 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 Shid9ee45c2014-02-27 15:38:11 -07009#include "tests/test-common.hpp"
Junxiao Shi65d00722014-02-17 10:50:20 -070010
11namespace nfd {
Junxiao Shid9ee45c2014-02-27 15:38:11 -070012namespace tests {
Junxiao Shi65d00722014-02-17 10:50:20 -070013
Junxiao Shid9ee45c2014-02-27 15:38:11 -070014BOOST_FIXTURE_TEST_SUITE(TableMeasurements, BaseFixture)
Junxiao Shi65d00722014-02-17 10:50:20 -070015
16BOOST_AUTO_TEST_CASE(Get_Parent)
17{
HangZhangc85a23c2014-03-01 15:55:55 +080018 NameTree nameTree(1024);
19 Measurements measurements(nameTree);
Junxiao Shic041ca32014-02-25 20:01:15 -070020
Junxiao Shi65d00722014-02-17 10:50:20 -070021 Name name0;
22 Name nameA ("ndn:/A");
23 Name nameAB("ndn:/A/B");
24
Junxiao Shi65d00722014-02-17 10:50:20 -070025 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
40BOOST_AUTO_TEST_SUITE_END()
41
Junxiao Shid9ee45c2014-02-27 15:38:11 -070042} // namespace tests
Junxiao Shi65d00722014-02-17 10:50:20 -070043} // namespace nfd