interest: flip default value of CanBePrefix to false

Refs: #4582
Change-Id: Ifc703e3c50d91954cd82ade8664e8fe9ec3a8154
diff --git a/tests/integration/default-can-be-prefix-unset.cpp b/tests/integration/default-can-be-prefix-unset.cpp
deleted file mode 100644
index 6c97feb..0000000
--- a/tests/integration/default-can-be-prefix-unset.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013-2020 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library 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 Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#define BOOST_TEST_MODULE ndn-cxx Integration (DefaultCanBePrefix)
-#include "tests/boost-test.hpp"
-
-#include "ndn-cxx/interest.hpp"
-
-namespace ndn {
-namespace tests {
-
-BOOST_AUTO_TEST_CASE(DefaultCanBePrefixUnset)
-{
-  Interest interest1("/I");
-  BOOST_CHECK_THROW(interest1.wireEncode(), std::logic_error);
-  Interest::s_errorIfCanBePrefixUnset = false;
-  Interest interest2(interest1.wireEncode());
-  BOOST_CHECK_EQUAL(interest2.getCanBePrefix(), true);
-}
-
-} // namespace tests
-} // namespace ndn
diff --git a/tests/unit/interest.t.cpp b/tests/unit/interest.t.cpp
index 33c4eb2..f119792 100644
--- a/tests/unit/interest.t.cpp
+++ b/tests/unit/interest.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -52,7 +52,7 @@
   Interest i;
   BOOST_CHECK_EQUAL(i.hasWire(), false);
   BOOST_CHECK_EQUAL(i.getName(), "/");
-  BOOST_CHECK_EQUAL(i.getCanBePrefix(), true);
+  BOOST_CHECK_EQUAL(i.getCanBePrefix(), false);
   BOOST_CHECK_EQUAL(i.getMustBeFresh(), false);
   BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true);
   BOOST_CHECK_EQUAL(i.hasNonce(), false);
@@ -737,11 +737,11 @@
 BOOST_AUTO_TEST_CASE(SetCanBePrefix)
 {
   Interest i;
-  BOOST_CHECK_EQUAL(i.getCanBePrefix(), true);
-  i.setCanBePrefix(false);
   BOOST_CHECK_EQUAL(i.getCanBePrefix(), false);
   i.setCanBePrefix(true);
   BOOST_CHECK_EQUAL(i.getCanBePrefix(), true);
+  i.setCanBePrefix(false);
+  BOOST_CHECK_EQUAL(i.getCanBePrefix(), false);
 }
 
 BOOST_AUTO_TEST_CASE(SetMustBeFresh)
diff --git a/tests/unit/security/certificate-cache.t.cpp b/tests/unit/security/certificate-cache.t.cpp
index 7d60506..f3b400e 100644
--- a/tests/unit/security/certificate-cache.t.cpp
+++ b/tests/unit/security/certificate-cache.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -75,13 +75,18 @@
 {
   BOOST_CHECK_NO_THROW(certCache.insert(cert));
 
-  // Find by interest
-  BOOST_CHECK(certCache.find(Interest(cert.getIdentity())) != nullptr);
-  BOOST_CHECK(certCache.find(Interest(cert.getKeyName())) != nullptr);
-  BOOST_CHECK(certCache.find(Interest(Name(cert.getName()).appendVersion())) == nullptr);
+  Interest i;
+  i.setCanBePrefix(true);
+  i.setName(cert.getIdentity());
+  BOOST_CHECK(certCache.find(i) != nullptr);
+  i.setName(cert.getKeyName());
+  BOOST_CHECK(certCache.find(i) != nullptr);
+  i.setName(Name(cert.getName()).appendVersion());
+  BOOST_CHECK(certCache.find(i) == nullptr);
 
   advanceClocks(12_s);
-  BOOST_CHECK(certCache.find(Interest(cert.getIdentity())) == nullptr);
+  i.setName(cert.getIdentity());
+  BOOST_CHECK(certCache.find(i) == nullptr);
 }
 
 BOOST_AUTO_TEST_SUITE_END() // TestCertificateCache
diff --git a/tests/unit/security/trust-anchor-container.t.cpp b/tests/unit/security/trust-anchor-container.t.cpp
index 18da58a..17151c8 100644
--- a/tests/unit/security/trust-anchor-container.t.cpp
+++ b/tests/unit/security/trust-anchor-container.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -150,12 +150,14 @@
 BOOST_AUTO_TEST_CASE(FindByInterest)
 {
   anchorContainer.insert("group1", certPath1.string(), 1_s);
-  Interest interest(identity1.getName());
-  BOOST_CHECK(anchorContainer.find(interest) != nullptr);
-  Interest interest1(identity1.getName().getPrefix(-1));
+  Interest interest1;
+  interest1.setCanBePrefix(true);
+  interest1.setName(identity1.getName());
   BOOST_CHECK(anchorContainer.find(interest1) != nullptr);
-  Interest interest2(Name(identity1.getName()).appendVersion());
-  BOOST_CHECK(anchorContainer.find(interest2) == nullptr);
+  interest1.setName(identity1.getName().getPrefix(-1));
+  BOOST_CHECK(anchorContainer.find(interest1) != nullptr);
+  interest1.setName(Name(identity1.getName()).appendVersion());
+  BOOST_CHECK(anchorContainer.find(interest1) == nullptr);
 
   auto cert3 = makeCert(identity1.getDefaultKey(), "3");
   auto cert4 = makeCert(identity1.getDefaultKey(), "4");
@@ -166,7 +168,7 @@
   anchorContainer.insert("group3", std::move(cert4));
   anchorContainer.insert("group4", std::move(cert5));
 
-  Interest interest3(cert3.getKeyName());
+  auto interest3 = Interest(cert3.getKeyName()).setCanBePrefix(true);
   const Certificate* foundCert = anchorContainer.find(interest3);
   BOOST_REQUIRE(foundCert != nullptr);
   BOOST_CHECK(interest3.getName().isPrefixOf(foundCert->getName()));