Remove ill-defined equality operators (part 1)
This removes overloaded operator== and operator!= from those classes
for which it is unclear what semantics such operators should have,
and whose current definitions are unsound or confusing for the user.
Refs: #4569
Change-Id: Ic385ac1e376a9916e762b1a0f790e4caae7c955b
diff --git a/ndn-cxx/data.cpp b/ndn-cxx/data.cpp
index abd4784..1ba5f4f 100644
--- a/ndn-cxx/data.cpp
+++ b/ndn-cxx/data.cpp
@@ -312,9 +312,10 @@
operator==(const Data& lhs, const Data& rhs)
{
return lhs.getName() == rhs.getName() &&
- lhs.getMetaInfo() == rhs.getMetaInfo() &&
+ lhs.getMetaInfo().wireEncode() == rhs.getMetaInfo().wireEncode() &&
lhs.getContent() == rhs.getContent() &&
- lhs.getSignature() == rhs.getSignature();
+ lhs.getSignature().getSignatureInfo() == rhs.getSignature().getSignatureInfo() &&
+ lhs.getSignature().getValue() == rhs.getSignature().getValue();
}
std::ostream&
diff --git a/ndn-cxx/interest.cpp b/ndn-cxx/interest.cpp
index a25147b..091038b 100644
--- a/ndn-cxx/interest.cpp
+++ b/ndn-cxx/interest.cpp
@@ -27,8 +27,6 @@
#include "ndn-cxx/security/transform/stream-sink.hpp"
#include "ndn-cxx/util/random.hpp"
-#include <boost/scope_exit.hpp>
-
#ifdef NDN_CXX_HAVE_STACKTRACE
#include <boost/stacktrace/stacktrace.hpp>
#endif
@@ -39,7 +37,6 @@
namespace ndn {
-BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Interest>));
BOOST_CONCEPT_ASSERT((WireEncodable<Interest>));
BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<Interest>));
BOOST_CONCEPT_ASSERT((WireDecodable<Interest>));
@@ -755,21 +752,6 @@
// ---- operators ----
-bool
-operator==(const Interest& lhs, const Interest& rhs)
-{
- bool wasCanBePrefixSetOnLhs = lhs.m_isCanBePrefixSet;
- bool wasCanBePrefixSetOnRhs = rhs.m_isCanBePrefixSet;
- lhs.m_isCanBePrefixSet = true;
- rhs.m_isCanBePrefixSet = true;
- BOOST_SCOPE_EXIT_ALL(&) {
- lhs.m_isCanBePrefixSet = wasCanBePrefixSetOnLhs;
- rhs.m_isCanBePrefixSet = wasCanBePrefixSetOnRhs;
- };
-
- return lhs.wireEncode() == rhs.wireEncode();
-}
-
std::ostream&
operator<<(std::ostream& os, const Interest& interest)
{
diff --git a/ndn-cxx/interest.hpp b/ndn-cxx/interest.hpp
index a127dae..fd79836 100644
--- a/ndn-cxx/interest.hpp
+++ b/ndn-cxx/interest.hpp
@@ -566,8 +566,6 @@
std::vector<Block> m_parameters; // NDN Packet Format v0.3 only
mutable Block m_wire;
-
- friend bool operator==(const Interest& lhs, const Interest& rhs);
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Interest);
@@ -575,15 +573,6 @@
std::ostream&
operator<<(std::ostream& os, const Interest& interest);
-bool
-operator==(const Interest& lhs, const Interest& rhs);
-
-inline bool
-operator!=(const Interest& lhs, const Interest& rhs)
-{
- return !(lhs == rhs);
-}
-
} // namespace ndn
#endif // NDN_INTEREST_HPP
diff --git a/ndn-cxx/meta-info.cpp b/ndn-cxx/meta-info.cpp
index b53a58c..4315fc8 100644
--- a/ndn-cxx/meta-info.cpp
+++ b/ndn-cxx/meta-info.cpp
@@ -25,7 +25,6 @@
namespace ndn {
-BOOST_CONCEPT_ASSERT((boost::EqualityComparable<MetaInfo>));
BOOST_CONCEPT_ASSERT((WireEncodable<MetaInfo>));
BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<MetaInfo>));
BOOST_CONCEPT_ASSERT((WireDecodable<MetaInfo>));
diff --git a/ndn-cxx/meta-info.hpp b/ndn-cxx/meta-info.hpp
index a5f6a44..fe3f19c 100644
--- a/ndn-cxx/meta-info.hpp
+++ b/ndn-cxx/meta-info.hpp
@@ -199,13 +199,6 @@
const Block*
findAppMetaInfo(uint32_t tlvType) const;
-public: // EqualityComparable concept
- bool
- operator==(const MetaInfo& other) const;
-
- bool
- operator!=(const MetaInfo& other) const;
-
private:
uint32_t m_type;
time::milliseconds m_freshnessPeriod;
@@ -220,18 +213,6 @@
std::ostream&
operator<<(std::ostream& os, const MetaInfo& info);
-inline bool
-MetaInfo::operator==(const MetaInfo& other) const
-{
- return wireEncode() == other.wireEncode();
-}
-
-inline bool
-MetaInfo::operator!=(const MetaInfo& other) const
-{
- return !(*this == other);
-}
-
} // namespace ndn
#endif // NDN_META_INFO_HPP
diff --git a/ndn-cxx/mgmt/nfd/cs-info.cpp b/ndn-cxx/mgmt/nfd/cs-info.cpp
index 9e6d29d..36cda7e 100644
--- a/ndn-cxx/mgmt/nfd/cs-info.cpp
+++ b/ndn-cxx/mgmt/nfd/cs-info.cpp
@@ -180,19 +180,23 @@
bool
operator==(const CsInfo& a, const CsInfo& b)
{
- return a.wireEncode() == b.wireEncode();
+ return a.getCapacity() == b.getCapacity() &&
+ a.getEnableAdmit() == b.getEnableAdmit() &&
+ a.getEnableServe() == b.getEnableServe() &&
+ a.getNEntries() == b.getNEntries() &&
+ a.getNHits() == b.getNHits() &&
+ a.getNMisses() == b.getNMisses();
}
std::ostream&
operator<<(std::ostream& os, const CsInfo& csi)
{
- os << "CS: "
- << csi.getNEntries() << " entries, " << csi.getCapacity() << " max, "
- << (csi.getEnableAdmit() ? "admit enabled, " : "admit disabled, ")
- << (csi.getEnableServe() ? "serve enabled, " : "serve disabled, ")
- << csi.getNHits() << (csi.getNHits() == 1 ? " hit, " : " hits, ")
- << csi.getNMisses() << (csi.getNMisses() == 1 ? " miss" : " misses");
- return os;
+ return os << "CsInfo: "
+ << csi.getNEntries() << " entries, " << csi.getCapacity() << " max, "
+ << (csi.getEnableAdmit() ? "admit enabled, " : "admit disabled, ")
+ << (csi.getEnableServe() ? "serve enabled, " : "serve disabled, ")
+ << csi.getNHits() << (csi.getNHits() == 1 ? " hit, " : " hits, ")
+ << csi.getNMisses() << (csi.getNMisses() == 1 ? " miss" : " misses");
}
} // namespace nfd
diff --git a/ndn-cxx/mgmt/nfd/cs-info.hpp b/ndn-cxx/mgmt/nfd/cs-info.hpp
index 6a185ad..199eddd 100644
--- a/ndn-cxx/mgmt/nfd/cs-info.hpp
+++ b/ndn-cxx/mgmt/nfd/cs-info.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -132,6 +132,7 @@
uint64_t m_nEntries;
uint64_t m_nHits;
uint64_t m_nMisses;
+
mutable Block m_wire;
};
diff --git a/ndn-cxx/signature.cpp b/ndn-cxx/signature.cpp
index 6c4787c..e3a07eb 100644
--- a/ndn-cxx/signature.cpp
+++ b/ndn-cxx/signature.cpp
@@ -23,7 +23,6 @@
namespace ndn {
-BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Signature>));
static_assert(std::is_base_of<tlv::Error, Signature::Error>::value,
"Signature::Error must inherit from tlv::Error");
@@ -64,10 +63,4 @@
m_value = value;
}
-bool
-operator==(const Signature& lhs, const Signature& rhs)
-{
- return lhs.getSignatureInfo() == rhs.getSignatureInfo() && lhs.getValue() == rhs.getValue();
-}
-
} // namespace ndn
diff --git a/ndn-cxx/signature.hpp b/ndn-cxx/signature.hpp
index c9e8030..1c02c60 100644
--- a/ndn-cxx/signature.hpp
+++ b/ndn-cxx/signature.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -151,15 +151,6 @@
mutable Block m_value;
};
-bool
-operator==(const Signature& lhs, const Signature& rhs);
-
-inline bool
-operator!=(const Signature& lhs, const Signature& rhs)
-{
- return !(lhs == rhs);
-}
-
} // namespace ndn
#endif // NDN_SIGNATURE_HPP
diff --git a/tests/unit/data.t.cpp b/tests/unit/data.t.cpp
index 9457089..56ca775 100644
--- a/tests/unit/data.t.cpp
+++ b/tests/unit/data.t.cpp
@@ -79,8 +79,6 @@
0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1
};
-// ---- constructor, encode, decode ----
-
BOOST_AUTO_TEST_CASE(DefaultConstructor)
{
Data d;
@@ -251,7 +249,9 @@
{
d.wireDecode("0607 0700 16031B0100"_block);
BOOST_CHECK_EQUAL(d.getName(), "/"); // empty Name is allowed in Data
- BOOST_CHECK_EQUAL(d.getMetaInfo(), MetaInfo());
+ BOOST_CHECK_EQUAL(d.getContentType(), tlv::ContentType_Blob);
+ BOOST_CHECK_EQUAL(d.getFreshnessPeriod(), 0_ms);
+ BOOST_CHECK_EQUAL(d.getFinalBlock().has_value(), false);
BOOST_CHECK_EQUAL(d.getContent().value_size(), 0);
BOOST_CHECK_EQUAL(d.getSignature().getType(), tlv::DigestSha256);
BOOST_CHECK_EQUAL(d.getSignature().getValue().value_size(), 0);
@@ -262,7 +262,9 @@
d.wireDecode("062C 0703080144 16031B0100 "
"1720612A79399E60304A9F701C1ECAC7956BF2F1B046E6C6F0D6C29B3FE3A29BAD76"_block);
BOOST_CHECK_EQUAL(d.getName(), "/D");
- BOOST_CHECK_EQUAL(d.getMetaInfo(), MetaInfo());
+ BOOST_CHECK_EQUAL(d.getContentType(), tlv::ContentType_Blob);
+ BOOST_CHECK_EQUAL(d.getFreshnessPeriod(), 0_ms);
+ BOOST_CHECK_EQUAL(d.getFinalBlock().has_value(), false);
BOOST_CHECK_EQUAL(d.getContent().value_size(), 0);
BOOST_CHECK_EQUAL(d.getSignature().getType(), tlv::DigestSha256);
BOOST_CHECK_EQUAL(d.getSignature().getValue().value_size(), 32);
@@ -282,7 +284,9 @@
d.wireDecode("063A 0703080144 FC00 1400 FC00 1500 FC00 16031B0100 FC00 "
"1720612A79399E60304A9F701C1ECAC7956BF2F1B046E6C6F0D6C29B3FE3A29BAD76 FC00"_block);
BOOST_CHECK_EQUAL(d.getName(), "/D");
- BOOST_CHECK_EQUAL(d.getMetaInfo(), MetaInfo());
+ BOOST_CHECK_EQUAL(d.getContentType(), tlv::ContentType_Blob);
+ BOOST_CHECK_EQUAL(d.getFreshnessPeriod(), 0_ms);
+ BOOST_CHECK_EQUAL(d.getFinalBlock().has_value(), false);
BOOST_CHECK_EQUAL(d.getContent().value_size(), 0);
BOOST_CHECK_EQUAL(d.getSignature().getType(), tlv::DigestSha256);
BOOST_CHECK_EQUAL(d.getSignature().getValue().value_size(), 32);
@@ -379,8 +383,6 @@
"sha256digest=28bad4b5275bd392dbb670c75cf0b66f13f7942b21e80f55c0e86b374753a548");
}
-// ---- operators ----
-
BOOST_AUTO_TEST_CASE(Equality)
{
Data a;
diff --git a/tests/unit/interest.t.cpp b/tests/unit/interest.t.cpp
index e7354e9..75aba88 100644
--- a/tests/unit/interest.t.cpp
+++ b/tests/unit/interest.t.cpp
@@ -101,8 +101,6 @@
BOOST_CHECK(i2.getHopLimit() == nullopt);
BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), false);
BOOST_CHECK_EQUAL(i2.isParametersDigestValid(), true);
-
- BOOST_CHECK_EQUAL(i1, i2);
}
BOOST_AUTO_TEST_CASE(Full)
@@ -144,8 +142,6 @@
BOOST_CHECK(i2.getHopLimit() == nullopt);
BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), false);
BOOST_CHECK_EQUAL(i2.isParametersDigestValid(), true);
-
- BOOST_CHECK_EQUAL(i1, i2);
}
BOOST_AUTO_TEST_CASE(ParametersSha256DigestComponent)
@@ -884,86 +880,6 @@
BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true);
}
-BOOST_AUTO_TEST_CASE(Equality)
-{
- Interest a;
- Interest b;
-
- // if nonce is not set, it would be set to a random value
- a.setNonce(1);
- b.setNonce(1);
-
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-
- // compare Name
- a.setName("/A");
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b.setName("/B");
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b.setName("/A");
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-
- // compare Selectors
- a.setChildSelector(1);
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b.setChildSelector(1);
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-
- // compare ForwardingHint
- a.setForwardingHint({{1, "/H"}});
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b.setForwardingHint({{1, "/H"}});
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-
- // compare Nonce
- a.setNonce(100);
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b.setNonce(100);
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-
- // compare InterestLifetime
- a.setInterestLifetime(10_s);
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b.setInterestLifetime(10_s);
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-
- // compare HopLimit
- a.setHopLimit(255);
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b.setHopLimit(255);
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-
- // compare ApplicationParameters
- a.setApplicationParameters("2404C0C1C2C3"_block);
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b.setApplicationParameters("2404C0C1C2C3"_block);
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-}
-
BOOST_AUTO_TEST_SUITE_END() // TestInterest
} // namespace tests
diff --git a/tests/unit/meta-info.t.cpp b/tests/unit/meta-info.t.cpp
index e6ad757..e5229bf 100644
--- a/tests/unit/meta-info.t.cpp
+++ b/tests/unit/meta-info.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -29,51 +29,49 @@
BOOST_AUTO_TEST_SUITE(TestMetaInfo)
-BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(EncodeDecodeEquality, 1)
-BOOST_AUTO_TEST_CASE(EncodeDecodeEquality)
+BOOST_AUTO_TEST_CASE(EncodeDecode)
{
// default values
MetaInfo a("1406 type=180100 freshness=190100"_block);
BOOST_CHECK_EQUAL(a.getType(), tlv::ContentType_Blob);
BOOST_CHECK_EQUAL(a.getFreshnessPeriod(), 0_ms);
- BOOST_CHECK(!a.getFinalBlock());
- BOOST_CHECK_EQUAL(a, a);
+ BOOST_CHECK(a.getFinalBlock() == nullopt);
MetaInfo b;
- BOOST_CHECK_NE(a, b);
+ BOOST_CHECK_NE(a.wireEncode(), b.wireEncode());
b.setType(a.getType());
b.setFreshnessPeriod(a.getFreshnessPeriod());
b.setFinalBlock(a.getFinalBlock());
+ BOOST_CHECK_NE(a.wireEncode(), b.wireEncode());
BOOST_CHECK_EQUAL(b.wireEncode(), "1400"_block);
- BOOST_CHECK_EQUAL(a, b); // expected failure #4569
// non-default values
- Block wire2 = "140C type=180101 freshness=190266B2 finalblock=1A03080141"_block;
+ Block wire2("140C type=180101 freshness=190266B2 finalblock=1A03080141"_block);
a.wireDecode(wire2);
BOOST_CHECK_EQUAL(a.getType(), tlv::ContentType_Link);
BOOST_CHECK_EQUAL(a.getFreshnessPeriod(), 26290_ms);
+ BOOST_REQUIRE(a.getFinalBlock().has_value());
BOOST_CHECK_EQUAL(*a.getFinalBlock(), name::Component("A"));
- BOOST_CHECK_NE(a, b);
+ BOOST_CHECK_NE(a.wireEncode(), b.wireEncode());
b.setType(a.getType());
b.setFreshnessPeriod(a.getFreshnessPeriod());
b.setFinalBlock(a.getFinalBlock());
BOOST_CHECK_EQUAL(b.wireEncode(), wire2);
- BOOST_CHECK_EQUAL(a, b);
- // FinalBlockId is typed name component
+ // FinalBlockId is a typed name component
Block wire3 = "1405 finalblock=1A03DD0141"_block;
a.wireDecode(wire3);
BOOST_CHECK_EQUAL(a.getType(), tlv::ContentType_Blob);
BOOST_CHECK_EQUAL(a.getFreshnessPeriod(), 0_ms);
+ BOOST_REQUIRE(a.getFinalBlock().has_value());
BOOST_CHECK_EQUAL(*a.getFinalBlock(), name::Component::fromEscapedString("221=A"));
- BOOST_CHECK_NE(a, b);
+ BOOST_CHECK_NE(a.wireEncode(), b.wireEncode());
b.setType(a.getType());
b.setFreshnessPeriod(a.getFreshnessPeriod());
b.setFinalBlock(a.getFinalBlock());
BOOST_CHECK_EQUAL(b.wireEncode(), wire3);
- BOOST_CHECK_EQUAL(a, b);
}
BOOST_AUTO_TEST_CASE(AppMetaInfo)
diff --git a/tests/unit/mgmt/nfd/cs-info.t.cpp b/tests/unit/mgmt/nfd/cs-info.t.cpp
index 9c1999c..3bc5f7b 100644
--- a/tests/unit/mgmt/nfd/cs-info.t.cpp
+++ b/tests/unit/mgmt/nfd/cs-info.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -107,15 +107,15 @@
{
CsInfo csi;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(csi),
- "CS: 0 entries, 0 max, admit disabled, serve disabled, 0 hits, 0 misses");
+ "CsInfo: 0 entries, 0 max, admit disabled, serve disabled, 0 hits, 0 misses");
csi = makeCsInfo();
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(csi),
- "CS: 5509 entries, 20177 max, admit disabled, serve enabled, 12951 hits, 28179 misses");
+ "CsInfo: 5509 entries, 20177 max, admit disabled, serve enabled, 12951 hits, 28179 misses");
csi.setEnableAdmit(true).setNHits(1).setNMisses(1);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(csi),
- "CS: 5509 entries, 20177 max, admit enabled, serve enabled, 1 hit, 1 miss");
+ "CsInfo: 5509 entries, 20177 max, admit enabled, serve enabled, 1 hit, 1 miss");
}
BOOST_AUTO_TEST_SUITE_END() // TestCsInfo
diff --git a/tests/unit/signature.t.cpp b/tests/unit/signature.t.cpp
deleted file mode 100644
index 0650b03..0000000
--- a/tests/unit/signature.t.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013-2018 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.
- */
-
-#include "ndn-cxx/signature.hpp"
-#include "ndn-cxx/security/digest-sha256.hpp"
-#include "ndn-cxx/security/signature-sha256-with-rsa.hpp"
-
-#include "tests/boost-test.hpp"
-
-namespace ndn {
-namespace tests {
-
-BOOST_AUTO_TEST_SUITE(TestSignature)
-
-BOOST_AUTO_TEST_CASE(Equality)
-{
- Signature a;
- Signature b;
-
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-
- a = SignatureSha256WithRsa();
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b = SignatureSha256WithRsa();
- static const uint8_t someData[256] = {};
- Block signatureValue = makeBinaryBlock(tlv::SignatureValue, someData, sizeof(someData));
- b.setValue(signatureValue);
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- a.setValue(signatureValue);
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-
- a = DigestSha256();
- b = SignatureSha256WithRsa();
- BOOST_CHECK_EQUAL(a == b, false);
- BOOST_CHECK_EQUAL(a != b, true);
-
- b = DigestSha256();
- BOOST_CHECK_EQUAL(a == b, true);
- BOOST_CHECK_EQUAL(a != b, false);
-}
-
-BOOST_AUTO_TEST_SUITE_END() // TestSignature
-
-} // namespace tests
-} // namespace ndn