docs: Update of copyright and license statement in all .hpp and .cpp files
Change-Id: I4082db67f2390482615a780d91a513f09d57a9a4
Refs: #1266
diff --git a/tests/table/cs.cpp b/tests/table/cs.cpp
index 5bb6eb7..f236d77 100644
--- a/tests/table/cs.cpp
+++ b/tests/table/cs.cpp
@@ -1,10 +1,28 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (C) 2014 Named Data Networking Project
- * See COPYING for copyright and distribution information.
+ * Copyright (c) 2014 Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology
*
- * Author: Ilya Moiseenko <iliamo@ucla.edu>
- */
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * \author Ilya Moiseenko <iliamo@ucla.edu>
+ **/
#include "table/cs.hpp"
#include "table/cs-entry.hpp"
@@ -32,13 +50,13 @@
BOOST_AUTO_TEST_CASE(Insertion)
{
Cs cs;
-
+
shared_ptr<Data> data = make_shared<Data>("/insertion");
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
data->setSignature(fakeSignature);
-
+
BOOST_CHECK_EQUAL(cs.insert(*data), true);
}
@@ -48,23 +66,23 @@
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
shared_ptr<Data> data = make_shared<Data>("/a");
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/b");
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
shared_ptr<Data> data3 = make_shared<Data>("/c");
data3->setSignature(fakeSignature);
cs.insert(*data3);
-
+
shared_ptr<Data> data4 = make_shared<Data>("/d");
data4->setSignature(fakeSignature);
cs.insert(*data4);
-
+
BOOST_CHECK_EQUAL(cs.size(), 4);
}
@@ -72,18 +90,18 @@
BOOST_AUTO_TEST_CASE(DuplicateInsertion)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
shared_ptr<Data> data0 = make_shared<Data>("/insert/smth");
data0->setSignature(fakeSignature);
BOOST_CHECK_EQUAL(cs.insert(*data0), true);
-
+
shared_ptr<Data> data = make_shared<Data>("/insert/duplicate");
data->setSignature(fakeSignature);
BOOST_CHECK_EQUAL(cs.insert(*data), true);
-
+
cs.insert(*data);
BOOST_CHECK_EQUAL(cs.size(), 2);
}
@@ -92,17 +110,17 @@
BOOST_AUTO_TEST_CASE(DuplicateInsertion2)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
shared_ptr<Data> data = make_shared<Data>("/insert/duplicate");
data->setSignature(fakeSignature);
BOOST_CHECK_EQUAL(cs.insert(*data), true);
-
+
cs.insert(*data);
BOOST_CHECK_EQUAL(cs.size(), 1);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/insert/original");
data2->setSignature(fakeSignature);
BOOST_CHECK_EQUAL(cs.insert(*data2), true);
@@ -112,20 +130,20 @@
BOOST_AUTO_TEST_CASE(InsertAndFind)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
Name name("/insert/and/find");
-
+
shared_ptr<Data> data = make_shared<Data>(name);
data->setSignature(fakeSignature);
BOOST_CHECK_EQUAL(cs.insert(*data), true);
-
+
shared_ptr<Interest> interest = make_shared<Interest>(name);
-
+
const Data* found = cs.find(*interest);
-
+
BOOST_REQUIRE(found != 0);
BOOST_CHECK_EQUAL(data->getName(), found->getName());
}
@@ -133,20 +151,20 @@
BOOST_AUTO_TEST_CASE(InsertAndNotFind)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
Name name("/insert/and/find");
shared_ptr<Data> data = make_shared<Data>(name);
data->setSignature(fakeSignature);
BOOST_CHECK_EQUAL(cs.insert(*data), true);
-
+
Name name2("/not/find");
shared_ptr<Interest> interest = make_shared<Interest>(name2);
-
+
const Data* found = cs.find(*interest);
-
+
BOOST_CHECK_EQUAL(found, static_cast<const Data*>(0));
}
@@ -154,15 +172,15 @@
BOOST_AUTO_TEST_CASE(InsertAndErase)
{
CsAccessor cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
shared_ptr<Data> data = make_shared<Data>("/insertandelete");
data->setSignature(fakeSignature);
cs.insert(*data);
BOOST_CHECK_EQUAL(cs.size(), 1);
-
+
cs.evictItem_accessor();
BOOST_CHECK_EQUAL(cs.size(), 0);
}
@@ -170,29 +188,29 @@
BOOST_AUTO_TEST_CASE(StalenessQueue)
{
CsAccessor cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
Name name2("/insert/fresh");
shared_ptr<Data> data2 = make_shared<Data>(name2);
data2->setFreshnessPeriod(time::milliseconds(5000));
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
Name name("/insert/expire");
shared_ptr<Data> data = make_shared<Data>(name);
data->setFreshnessPeriod(time::milliseconds(500));
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
BOOST_CHECK_EQUAL(cs.size(), 2);
-
+
sleep(1);
-
+
cs.evictItem_accessor();
BOOST_CHECK_EQUAL(cs.size(), 1);
-
+
shared_ptr<Interest> interest = make_shared<Interest>(name2);
const Data* found = cs.find(*interest);
BOOST_REQUIRE(found != 0);
@@ -210,23 +228,23 @@
shared_ptr<Data> data = make_shared<Data>("/a");
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/b");
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
shared_ptr<Data> data3 = make_shared<Data>("/c");
data3->setSignature(fakeSignature);
cs.insert(*data3);
-
+
shared_ptr<Data> data4 = make_shared<Data>("/d");
data4->setSignature(fakeSignature);
cs.insert(*data4);
-
+
shared_ptr<Data> data5 = make_shared<Data>("/e");
data5->setSignature(fakeSignature);
cs.insert(*data5);
-
+
BOOST_CHECK_EQUAL(cs.size(), 4);
}
@@ -234,33 +252,33 @@
BOOST_AUTO_TEST_CASE(Replacement2)
{
Cs cs(3);
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
shared_ptr<Data> data = make_shared<Data>("/a");
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/b");
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
shared_ptr<Data> data3 = make_shared<Data>("/c");
data3->setSignature(fakeSignature);
cs.insert(*data3);
-
+
shared_ptr<Data> data4 = make_shared<Data>("/d");
data4->setSignature(fakeSignature);
cs.insert(*data4);
-
+
BOOST_CHECK_EQUAL(cs.size(), 3);
}
BOOST_AUTO_TEST_CASE(InsertAndEraseByName)
{
CsAccessor cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
@@ -268,10 +286,10 @@
shared_ptr<Data> data = make_shared<Data>(name);
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
uint8_t digest1[32];
ndn::ndn_digestSha256(data->wireEncode().wire(), data->wireEncode().size(), digest1);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/a");
data2->setSignature(fakeSignature);
cs.insert(*data2);
@@ -281,7 +299,7 @@
cs.insert(*data3);
BOOST_CHECK_EQUAL(cs.size(), 3);
-
+
name.append(digest1, 32);
cs.erase(name);
BOOST_CHECK_EQUAL(cs.size(), 2);
@@ -294,12 +312,12 @@
shared_ptr<Data> data = make_shared<Data>("/digest/compute");
data->setSignature(fakeSignature);
-
+
uint8_t digest1[32];
ndn::ndn_digestSha256(data->wireEncode().wire(), data->wireEncode().size(), digest1);
-
+
cs::Entry* entry = new cs::Entry(*data, false);
-
+
BOOST_CHECK_EQUAL_COLLECTIONS(digest1, digest1+32,
entry->getDigest()->buf(), entry->getDigest()->buf()+32);
}
@@ -307,34 +325,34 @@
BOOST_AUTO_TEST_CASE(InsertCanonical)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
shared_ptr<Data> data = make_shared<Data>("/a");
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/b");
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
shared_ptr<Data> data3 = make_shared<Data>("/c");
data3->setSignature(fakeSignature);
cs.insert(*data3);
-
+
shared_ptr<Data> data4 = make_shared<Data>("/d");
data4->setSignature(fakeSignature);
cs.insert(*data4);
-
+
shared_ptr<Data> data5 = make_shared<Data>("/c/c/1/2/3/4/5/6");
data5->setSignature(fakeSignature);
cs.insert(*data5);
-
+
shared_ptr<Data> data6 = make_shared<Data>("/c/c/1/2/3");
data6->setSignature(fakeSignature);
cs.insert(*data6);
-
+
shared_ptr<Data> data7 = make_shared<Data>("/c/c/1");
data7->setSignature(fakeSignature);
cs.insert(*data7);
@@ -343,37 +361,37 @@
BOOST_AUTO_TEST_CASE(EraseCanonical)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
shared_ptr<Data> data = make_shared<Data>("/a");
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/b");
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
shared_ptr<Data> data3 = make_shared<Data>("/c");
data3->setSignature(fakeSignature);
cs.insert(*data3);
-
+
shared_ptr<Data> data4 = make_shared<Data>("/d");
data4->setSignature(fakeSignature);
cs.insert(*data4);
-
+
uint8_t digest1[32];
ndn::ndn_digestSha256(data->wireEncode().wire(), data->wireEncode().size(), digest1);
shared_ptr<Data> data5 = make_shared<Data>("/c/c/1/2/3/4/5/6");
data5->setSignature(fakeSignature);
cs.insert(*data5);
-
+
shared_ptr<Data> data6 = make_shared<Data>("/c/c/1/2/3");
data6->setSignature(fakeSignature);
cs.insert(*data6);
-
+
shared_ptr<Data> data7 = make_shared<Data>("/c/c/1");
data7->setSignature(fakeSignature);
cs.insert(*data7);
@@ -387,15 +405,15 @@
BOOST_AUTO_TEST_CASE(ImplicitDigestSelector)
{
CsAccessor cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
Name name("/digest/works");
shared_ptr<Data> data = make_shared<Data>(name);
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/a");
data2->setSignature(fakeSignature);
cs.insert(*data2);
@@ -403,24 +421,24 @@
shared_ptr<Data> data3 = make_shared<Data>("/z/z/z");
data3->setSignature(fakeSignature);
cs.insert(*data3);
-
+
uint8_t digest1[32];
ndn::ndn_digestSha256(data->wireEncode().wire(), data->wireEncode().size(), digest1);
-
+
uint8_t digest2[32] = {0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1};
-
+
shared_ptr<Interest> interest = make_shared<Interest>(boost::cref(Name(name).append(digest1, 32)));
interest->setMinSuffixComponents(0);
interest->setMaxSuffixComponents(0);
-
+
const Data* found = cs.find(*interest);
BOOST_CHECK_NE(found, static_cast<const Data*>(0));
BOOST_CHECK_EQUAL(found->getName(), name);
-
+
shared_ptr<Interest> interest2 = make_shared<Interest>(boost::cref(Name(name).append(digest2, 32)));
interest2->setMinSuffixComponents(0);
interest2->setMaxSuffixComponents(0);
-
+
const Data* notfound = cs.find(*interest2);
BOOST_CHECK_EQUAL(notfound, static_cast<const Data*>(0));
}
@@ -428,43 +446,43 @@
BOOST_AUTO_TEST_CASE(ChildSelector)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
shared_ptr<Data> data = make_shared<Data>("/a");
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/b");
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
shared_ptr<Data> data4 = make_shared<Data>("/d");
data4->setSignature(fakeSignature);
cs.insert(*data4);
-
+
shared_ptr<Data> data5 = make_shared<Data>("/c/c");
data5->setSignature(fakeSignature);
cs.insert(*data5);
-
+
shared_ptr<Data> data6 = make_shared<Data>("/c/f");
data6->setSignature(fakeSignature);
cs.insert(*data6);
-
+
shared_ptr<Data> data7 = make_shared<Data>("/c/n");
data7->setSignature(fakeSignature);
cs.insert(*data7);
-
+
shared_ptr<Interest> interest = make_shared<Interest>("/c");
interest->setChildSelector(1);
-
+
const Data* found = cs.find(*interest);
BOOST_CHECK_EQUAL(found->getName(), "/c/n");
shared_ptr<Interest> interest2 = make_shared<Interest>("/c");
interest2->setChildSelector(0);
-
+
const Data* found2 = cs.find(*interest2);
BOOST_CHECK_EQUAL(found2->getName(), "/c/c");
}
@@ -472,29 +490,29 @@
BOOST_AUTO_TEST_CASE(ChildSelector2)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
shared_ptr<Data> data = make_shared<Data>("/a/b/1");
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/a/b/2");
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
shared_ptr<Data> data3 = make_shared<Data>("/a/z/1");
data3->setSignature(fakeSignature);
cs.insert(*data3);
-
+
shared_ptr<Data> data4 = make_shared<Data>("/a/z/2");
data4->setSignature(fakeSignature);
cs.insert(*data4);
-
+
shared_ptr<Interest> interest = make_shared<Interest>("/a");
interest->setChildSelector(1);
-
+
const Data* found = cs.find(*interest);
BOOST_CHECK_EQUAL(found->getName(), "/a/z/1");
}
@@ -502,21 +520,21 @@
BOOST_AUTO_TEST_CASE(MustBeFreshSelector)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
Name name("/insert/nonfresh");
shared_ptr<Data> data = make_shared<Data>(name);
data->setFreshnessPeriod(time::milliseconds(500));
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
sleep(1);
-
+
shared_ptr<Interest> interest = make_shared<Interest>(name);
interest->setMustBeFresh(true);
-
+
const Data* found = cs.find(*interest);
BOOST_CHECK_EQUAL(found, static_cast<const Data*>(0));
}
@@ -524,56 +542,56 @@
BOOST_AUTO_TEST_CASE(MinMaxComponentsSelector)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
shared_ptr<Data> data = make_shared<Data>("/a");
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/b");
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
shared_ptr<Data> data4 = make_shared<Data>("/d");
data4->setSignature(fakeSignature);
cs.insert(*data4);
-
+
shared_ptr<Data> data5 = make_shared<Data>("/c/c/1/2/3/4/5/6");
data5->setSignature(fakeSignature);
cs.insert(*data5);
-
+
shared_ptr<Data> data6 = make_shared<Data>("/c/c/6/7/8/9");
data6->setSignature(fakeSignature);
cs.insert(*data6);
-
+
shared_ptr<Data> data7 = make_shared<Data>("/c/c/1/2/3");
data7->setSignature(fakeSignature);
cs.insert(*data7);
-
+
shared_ptr<Data> data8 = make_shared<Data>("/c/c/1");
data8->setSignature(fakeSignature);
cs.insert(*data8);
-
+
shared_ptr<Interest> interest = make_shared<Interest>("/c/c");
interest->setMinSuffixComponents(3);
interest->setChildSelector(0);
-
+
const Data* found = cs.find(*interest);
BOOST_CHECK_EQUAL(found->getName(), "/c/c/1/2/3/4/5/6");
shared_ptr<Interest> interest2 = make_shared<Interest>("/c/c");
interest2->setMinSuffixComponents(4);
interest2->setChildSelector(1);
-
+
const Data* found2 = cs.find(*interest2);
BOOST_CHECK_EQUAL(found2->getName(), "/c/c/6/7/8/9");
-
+
shared_ptr<Interest> interest3 = make_shared<Interest>("/c/c");
interest3->setMaxSuffixComponents(2);
interest3->setChildSelector(1);
-
+
const Data* found3 = cs.find(*interest3);
BOOST_CHECK_EQUAL(found3->getName(), "/c/c/1");
}
@@ -581,22 +599,22 @@
BOOST_AUTO_TEST_CASE(ExcludeSelector)
{
Cs cs;
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
-
+
shared_ptr<Data> data = make_shared<Data>("/a");
data->setSignature(fakeSignature);
cs.insert(*data);
-
+
shared_ptr<Data> data2 = make_shared<Data>("/b");
data2->setSignature(fakeSignature);
cs.insert(*data2);
-
+
shared_ptr<Data> data3 = make_shared<Data>("/c/a");
data3->setSignature(fakeSignature);
cs.insert(*data3);
-
+
shared_ptr<Data> data4 = make_shared<Data>("/d");
data4->setSignature(fakeSignature);
cs.insert(*data4);
@@ -604,37 +622,37 @@
shared_ptr<Data> data5 = make_shared<Data>("/c/c");
data5->setSignature(fakeSignature);
cs.insert(*data5);
-
+
shared_ptr<Data> data6 = make_shared<Data>("/c/f");
data6->setSignature(fakeSignature);
cs.insert(*data6);
-
+
shared_ptr<Data> data7 = make_shared<Data>("/c/n");
data7->setSignature(fakeSignature);
cs.insert(*data7);
-
+
shared_ptr<Interest> interest = make_shared<Interest>("/c");
interest->setChildSelector(1);
Exclude e;
e.excludeOne (Name::Component("n"));
interest->setExclude(e);
-
+
const Data* found = cs.find(*interest);
BOOST_CHECK_EQUAL(found->getName(), "/c/f");
shared_ptr<Interest> interest2 = make_shared<Interest>("/c");
interest2->setChildSelector(0);
-
+
Exclude e2;
e2.excludeOne (Name::Component("a"));
interest2->setExclude(e2);
const Data* found2 = cs.find(*interest2);
BOOST_CHECK_EQUAL(found2->getName(), "/c/c");
-
+
shared_ptr<Interest> interest3 = make_shared<Interest>("/c");
interest3->setChildSelector(0);
-
+
Exclude e3;
e3.excludeOne (Name::Component("c"));
interest3->setExclude(e3);
@@ -654,21 +672,21 @@
shared_ptr<Data> data = make_shared<Data>(name);
data->setFreshnessPeriod(time::milliseconds(99999));
data->setContent(reinterpret_cast<const uint8_t*>(&id), sizeof(id));
-
+
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0));
data->setSignature(fakeSignature);
-
+
m_cs.insert(*data);
}
-
+
Interest&
startInterest(const Name& name)
{
m_interest = make_shared<Interest>(name);
return *m_interest;
}
-
+
uint32_t
find()
{
@@ -682,7 +700,7 @@
}
return *reinterpret_cast<const uint32_t*>(content.value());
}
-
+
protected:
Cs m_cs;
shared_ptr<Interest> m_interest;
@@ -693,7 +711,7 @@
BOOST_AUTO_TEST_CASE(EmptyDataName)
{
insert(1, "ndn:/");
-
+
startInterest("ndn:/");
BOOST_CHECK_EQUAL(find(), 1);
}
@@ -701,7 +719,7 @@
BOOST_AUTO_TEST_CASE(EmptyInterestName)
{
insert(1, "ndn:/A");
-
+
startInterest("ndn:/");
BOOST_CHECK_EQUAL(find(), 1);
}
@@ -714,7 +732,7 @@
insert(4, "ndn:/B/q/1");
insert(5, "ndn:/B/q/2");
insert(6, "ndn:/C");
-
+
startInterest("ndn:/B");
BOOST_CHECK_EQUAL(find(), 2);
}
@@ -727,7 +745,7 @@
insert(4, "ndn:/B/q/1");
insert(5, "ndn:/B/q/2");
insert(6, "ndn:/C");
-
+
startInterest("ndn:/B")
.setChildSelector(1);
BOOST_CHECK_EQUAL(find(), 4);
@@ -740,7 +758,7 @@
insert(3, "ndn:/A/C");
insert(4, "ndn:/A");
insert(5, "ndn:/D");
-
+
// Intuitively you would think Data 4 should be between Data 1 and 2,
// but Data 4 has full Name ndn:/A/<32-octet hash>.
startInterest("ndn:/A");
@@ -754,7 +772,7 @@
insert(3, "ndn:/A/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); // 33 'B's
insert(4, "ndn:/A/CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"); // 33 'C's
insert(5, "ndn:/D");
-
+
// Data 2 is returned, because <32-octet hash> is less than Data 3.
startInterest("ndn:/A");
BOOST_CHECK_EQUAL(find(), 2);
@@ -768,42 +786,42 @@
insert(4, "ndn:/D/1");
insert(5, "ndn:/E");
insert(6, "ndn:/");
-
+
startInterest("ndn:/")
.setChildSelector(1)
.setMinSuffixComponents(0);
BOOST_CHECK_EQUAL(find(), 6);
-
+
startInterest("ndn:/")
.setChildSelector(1)
.setMinSuffixComponents(1);
BOOST_CHECK_EQUAL(find(), 6);
-
+
startInterest("ndn:/")
.setChildSelector(1)
.setMinSuffixComponents(2);
BOOST_CHECK_EQUAL(find(), 5);
-
+
startInterest("ndn:/")
.setChildSelector(1)
.setMinSuffixComponents(3);
BOOST_CHECK_EQUAL(find(), 4);
-
+
startInterest("ndn:/")
.setChildSelector(1)
.setMinSuffixComponents(4);
BOOST_CHECK_EQUAL(find(), 3);
-
+
startInterest("ndn:/")
.setChildSelector(1)
.setMinSuffixComponents(5);
BOOST_CHECK_EQUAL(find(), 2);
-
+
startInterest("ndn:/")
.setChildSelector(1)
.setMinSuffixComponents(6);
BOOST_CHECK_EQUAL(find(), 1);
-
+
startInterest("ndn:/")
.setChildSelector(1)
.setMinSuffixComponents(7);
@@ -819,31 +837,31 @@
insert(5, "ndn:/A/B/C/D");
insert(6, "ndn:/A/B/C/D/E");
// Order is 6,5,4,3,2,1, because <32-octet hash> is greater than a 1-octet component.
-
+
startInterest("ndn:/")
.setMaxSuffixComponents(0);
BOOST_CHECK_EQUAL(find(), 0);
-
+
startInterest("ndn:/")
.setMaxSuffixComponents(1);
BOOST_CHECK_EQUAL(find(), 1);
-
+
startInterest("ndn:/")
.setMaxSuffixComponents(2);
BOOST_CHECK_EQUAL(find(), 2);
-
+
startInterest("ndn:/")
.setMaxSuffixComponents(3);
BOOST_CHECK_EQUAL(find(), 3);
-
+
startInterest("ndn:/")
.setMaxSuffixComponents(4);
BOOST_CHECK_EQUAL(find(), 4);
-
+
startInterest("ndn:/")
.setMaxSuffixComponents(5);
BOOST_CHECK_EQUAL(find(), 5);
-
+
startInterest("ndn:/")
.setMaxSuffixComponents(6);
BOOST_CHECK_EQUAL(find(), 6);
@@ -854,15 +872,15 @@
insert(1, "ndn:/A");
insert(2, "ndn:/A");
// We don't know which comes first, but there must be some order
-
+
startInterest("ndn:/A")
.setChildSelector(0);
uint32_t leftmost = find();
-
+
startInterest("ndn:/A")
.setChildSelector(1);
uint32_t rightmost = find();
-
+
BOOST_CHECK_NE(leftmost, rightmost);
}
@@ -871,13 +889,13 @@
insert(1, "ndn:/A/B");
insert(2, "ndn:/A");
insert(3, "ndn:/A/CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"); // 33 'C's
-
+
startInterest("ndn:/A")
.setExclude(Exclude().excludeBefore(ndn::name::Component(reinterpret_cast<const uint8_t*>(
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"), 31))); // 31 0xFF's
BOOST_CHECK_EQUAL(find(), 2);
-
+
startInterest("ndn:/A")
.setChildSelector(1)
.setExclude(Exclude().excludeAfter(ndn::name::Component(reinterpret_cast<const uint8_t*>(