face: Fix a serious bug with incoming interests processing

There was an error in logic of matching incoming interests to the
registered prefix table.  There was actually no matching at all, only
search for the longest prefix.

Change-Id: I701655eb4f488938838df78fcb6730968bb1bbbf
diff --git a/tests/test-faces.cpp b/tests/test-faces.cpp
index 9fc5860..1fab695 100644
--- a/tests/test-faces.cpp
+++ b/tests/test-faces.cpp
@@ -19,6 +19,7 @@
     , timeoutCount(0)
     , regPrefixId(0)
     , inInterestCount(0)
+    , inInterestCount2(0)
     , regFailedCount(0)
   {
   }
@@ -44,6 +45,14 @@
   }
 
   void
+  onInterest2(Face& face)
+  {
+    ++inInterestCount2;
+
+    face.unsetInterestFilter(regPrefixId2);
+  }
+
+  void
   onRegFailed()
   {
     ++regFailedCount;
@@ -69,7 +78,9 @@
   uint32_t timeoutCount;
 
   const RegisteredPrefixId* regPrefixId;
+  const RegisteredPrefixId* regPrefixId2;
   uint32_t inInterestCount;
+  uint32_t inInterestCount2;
   uint32_t regFailedCount;
 };
 
@@ -144,6 +155,36 @@
   BOOST_CHECK_EQUAL(dataCount, 0);
 }
 
+BOOST_FIXTURE_TEST_CASE (SetTwoFilters, FacesFixture)
+{
+  Face face;
+  Face face2(face.ioService());
+  Scheduler scheduler(*face.ioService());
+  scheduler.scheduleEvent(time::seconds(0.3),
+                          bind(&FacesFixture::terminate, this, func_lib::ref(face)));
+  
+  regPrefixId = face.setInterestFilter("/Hello/World",
+                                       bind(&FacesFixture::onInterest, this, func_lib::ref(face)),
+                                       bind(&FacesFixture::onRegFailed, this));
+  
+  regPrefixId2 = face.setInterestFilter("/Los/Angeles/Lakers",
+                                       bind(&FacesFixture::onInterest2, this, func_lib::ref(face)),
+                                       bind(&FacesFixture::onRegFailed, this));
+
+
+  scheduler.scheduleEvent(time::seconds(0.2),
+                          bind(&FacesFixture::expressInterest, this,
+                               func_lib::ref(face2), Name("/Hello/World/!")));
+  
+  BOOST_REQUIRE_NO_THROW(face.processEvents());
+
+  BOOST_CHECK_EQUAL(regFailedCount, 0);  
+  BOOST_CHECK_EQUAL(inInterestCount, 1);  
+  BOOST_CHECK_EQUAL(inInterestCount2, 0);  
+  BOOST_CHECK_EQUAL(timeoutCount, 1);
+  BOOST_CHECK_EQUAL(dataCount, 0);
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace ndn