blob: 98676b52a07a21531d88fdb2354aada52a99f796 [file] [log] [blame]
Junxiao Shi65d00722014-02-17 10:50:20 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -07003 * 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 Shi65d00722014-02-17 10:50:20 -070024
25#include "table/measurements.hpp"
26
Junxiao Shid9ee45c2014-02-27 15:38:11 -070027#include "tests/test-common.hpp"
Junxiao Shi65d00722014-02-17 10:50:20 -070028
29namespace nfd {
Junxiao Shid9ee45c2014-02-27 15:38:11 -070030namespace tests {
Junxiao Shi65d00722014-02-17 10:50:20 -070031
Junxiao Shid9ee45c2014-02-27 15:38:11 -070032BOOST_FIXTURE_TEST_SUITE(TableMeasurements, BaseFixture)
Junxiao Shi65d00722014-02-17 10:50:20 -070033
34BOOST_AUTO_TEST_CASE(Get_Parent)
35{
Haowei Yuanf52dac72014-03-24 23:35:03 -050036 NameTree nameTree;
HangZhangc85a23c2014-03-01 15:55:55 +080037 Measurements measurements(nameTree);
Junxiao Shic041ca32014-02-25 20:01:15 -070038
Junxiao Shi65d00722014-02-17 10:50:20 -070039 Name name0;
40 Name nameA ("ndn:/A");
41 Name nameAB("ndn:/A/B");
42
Junxiao Shi65d00722014-02-17 10:50:20 -070043 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
58BOOST_AUTO_TEST_SUITE_END()
59
Junxiao Shid9ee45c2014-02-27 15:38:11 -070060} // namespace tests
Junxiao Shi65d00722014-02-17 10:50:20 -070061} // namespace nfd