nrd: basic implementation of rib
Change-Id: I0d6acf8188d39068081babd8c23f6ea6eb3c9406
diff --git a/tests/main.cpp b/tests/main.cpp
new file mode 100644
index 0000000..a7e827d
--- /dev/null
+++ b/tests/main.cpp
@@ -0,0 +1,10 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#define BOOST_TEST_MAIN 1
+#define BOOST_TEST_DYN_LINK 1
+
+#include <boost/test/unit_test.hpp>
diff --git a/tests/test-rib.cpp b/tests/test-rib.cpp
new file mode 100644
index 0000000..c9a5dff
--- /dev/null
+++ b/tests/test-rib.cpp
@@ -0,0 +1,56 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "rib.hpp"
+
+#include <boost/test/unit_test.hpp>
+
+namespace ndn {
+namespace nrd {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(TestRib)
+
+BOOST_AUTO_TEST_CASE(Basic)
+{
+ Rib rib;
+
+ PrefixRegOptions options1;
+ options1.setName("/hello/world");
+ options1.setFlags(tlv::nrd::NDN_FORW_CHILD_INHERIT | tlv::nrd::NDN_FORW_CAPTURE);
+ options1.setCost(10);
+ options1.setExpirationPeriod(1500);
+
+ PrefixRegOptions options2;
+ options2.setName("/hello/world");
+ options2.setFlags(tlv::nrd::NDN_FORW_CHILD_INHERIT);
+ options2.setExpirationPeriod(0);
+
+ rib.insert(options1);
+ BOOST_CHECK_EQUAL(rib.size(), 1);
+
+ rib.insert(options2);
+ BOOST_CHECK_EQUAL(rib.size(), 1);
+
+ options2.setName("/foo/bar");
+ rib.insert(options2);
+ BOOST_CHECK_EQUAL(rib.size(), 2);
+
+ rib.erase(options2);
+ BOOST_CHECK_EQUAL(rib.size(), 1);
+
+ BOOST_CHECK(rib.find(options2) == rib.end());
+ BOOST_CHECK(rib.find(options1) != rib.end());
+
+ rib.erase(options1);
+ BOOST_CHECK(rib.empty());
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace nrd
+} // namespace ndn