blob: 43601754d5936eb65f8a9f475a39c88e8a8e5cd4 [file] [log] [blame]
Obaid793401d2014-02-27 19:13:49 -06001/* -*- 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 "rib.hpp"
8
9#include <boost/test/unit_test.hpp>
10
11namespace ndn {
12namespace nrd {
13namespace tests {
14
15BOOST_AUTO_TEST_SUITE(TestRib)
16
17BOOST_AUTO_TEST_CASE(Basic)
18{
19 Rib rib;
20
21 PrefixRegOptions options1;
22 options1.setName("/hello/world");
23 options1.setFlags(tlv::nrd::NDN_FORW_CHILD_INHERIT | tlv::nrd::NDN_FORW_CAPTURE);
24 options1.setCost(10);
Obaidea56c612014-03-17 22:50:47 -050025 options1.setExpirationPeriod(time::milliseconds(1500));
Obaid793401d2014-02-27 19:13:49 -060026
27 PrefixRegOptions options2;
28 options2.setName("/hello/world");
29 options2.setFlags(tlv::nrd::NDN_FORW_CHILD_INHERIT);
Obaidea56c612014-03-17 22:50:47 -050030 options2.setExpirationPeriod(time::seconds(0));
Obaid793401d2014-02-27 19:13:49 -060031
32 rib.insert(options1);
33 BOOST_CHECK_EQUAL(rib.size(), 1);
34
35 rib.insert(options2);
36 BOOST_CHECK_EQUAL(rib.size(), 1);
37
38 options2.setName("/foo/bar");
39 rib.insert(options2);
40 BOOST_CHECK_EQUAL(rib.size(), 2);
41
42 rib.erase(options2);
43 BOOST_CHECK_EQUAL(rib.size(), 1);
44
45 BOOST_CHECK(rib.find(options2) == rib.end());
46 BOOST_CHECK(rib.find(options1) != rib.end());
47
48 rib.erase(options1);
49 BOOST_CHECK(rib.empty());
50}
51
52BOOST_AUTO_TEST_SUITE_END()
53
54} // namespace tests
55} // namespace nrd
56} // namespace ndn