table: Evict unsolicited Data in FIFO order

Change-Id: Iba97441e3e23e686da0612810b09108090e64aca
Refs: #2043
diff --git a/tests/daemon/table/cs.cpp b/tests/daemon/table/cs.cpp
index 3592290..1f95894 100644
--- a/tests/daemon/table/cs.cpp
+++ b/tests/daemon/table/cs.cpp
@@ -81,7 +81,6 @@
   BOOST_CHECK_EQUAL(cs.size(), 4);
 }
 
-
 BOOST_AUTO_TEST_CASE(DuplicateInsertion)
 {
   Cs cs;
@@ -187,6 +186,42 @@
   BOOST_CHECK_EQUAL(found->getName(), name2);
 }
 
+BOOST_AUTO_TEST_CASE(Bug2043) // eviction order of unsolicited packets
+{
+  Cs cs(3);
+
+  cs.insert(*makeData("/a"), true);
+  cs.insert(*makeData("/b"), true);
+  cs.insert(*makeData("/c"), true);
+  BOOST_CHECK_EQUAL(cs.size(), 3);
+
+  cs.insert(*makeData("/d"), true);
+  BOOST_CHECK_EQUAL(cs.size(), 3);
+
+  const Data* oldestData = cs.find(Interest("/a"));
+  const Data* newestData = cs.find(Interest("/c"));
+  BOOST_CHECK(oldestData == 0);
+  BOOST_CHECK(newestData != 0);
+}
+
+BOOST_AUTO_TEST_CASE(UnsolicitedWithSolicitedEvictionOrder)
+{
+  Cs cs(3);
+
+  cs.insert(*makeData("/a"), true);
+  cs.insert(*makeData("/b"), false);
+  cs.insert(*makeData("/c"), true);
+  BOOST_CHECK_EQUAL(cs.size(), 3);
+
+  cs.insert(*makeData("/d"), true);
+  BOOST_CHECK_EQUAL(cs.size(), 3);
+
+  const Data* oldestData = cs.find(Interest("/a"));
+  const Data* newestData = cs.find(Interest("/c"));
+  BOOST_CHECK(oldestData == 0);
+  BOOST_CHECK(newestData != 0);
+}
+
 //even max size
 BOOST_AUTO_TEST_CASE(ReplacementEvenSize)
 {