blob: c9a5dff77f9d6c2129314be3bc1e0ed54cc5caf2 [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);
25 options1.setExpirationPeriod(1500);
26
27 PrefixRegOptions options2;
28 options2.setName("/hello/world");
29 options2.setFlags(tlv::nrd::NDN_FORW_CHILD_INHERIT);
30 options2.setExpirationPeriod(0);
31
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