encoding: reorganize Block class code
* Improve Doxygen.
* Consolidate and simplify constructors.
* Reorder class methods in cpp file to match hpp.
* Make operator== and operator!= non-member functions.
* Improve exception messages.
* Update code style.
refs #4171
Change-Id: I4cc0393f43a24a500b0efff90108ad1b42f5fa47
diff --git a/tests/unit-tests/encoding/block.t.cpp b/tests/unit-tests/encoding/block.t.cpp
index 599f37c..02b1677 100644
--- a/tests/unit-tests/encoding/block.t.cpp
+++ b/tests/unit-tests/encoding/block.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -187,9 +187,9 @@
BOOST_CHECK(derivedBlock == Block(buffer + 2, 3));
Buffer otherBuffer(buffer, sizeof(buffer));
- BOOST_CHECK_THROW(Block(block, otherBuffer.begin(), block.end()), Block::Error);
- BOOST_CHECK_THROW(Block(block, block.begin(), otherBuffer.end()), Block::Error);
- BOOST_CHECK_THROW(Block(block, otherBuffer.begin(), otherBuffer.end()), Block::Error);
+ BOOST_CHECK_THROW(Block(block, otherBuffer.begin(), block.end()), std::invalid_argument);
+ BOOST_CHECK_THROW(Block(block, block.begin(), otherBuffer.end()), std::invalid_argument);
+ BOOST_CHECK_THROW(Block(block, otherBuffer.begin(), otherBuffer.end()), std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(FromBlockCopyOnWriteModifyOriginal)
diff --git a/tests/unit-tests/interest.t.cpp b/tests/unit-tests/interest.t.cpp
index d0345a4..a4c78c0 100644
--- a/tests/unit-tests/interest.t.cpp
+++ b/tests/unit-tests/interest.t.cpp
@@ -200,6 +200,7 @@
Data data("ndn:/A/D");
SignatureSha256WithRsa signature(KeyLocator("ndn:/B"));
+ signature.setValue(encoding::makeEmptyBlock(tlv::SignatureValue));
data.setSignature(signature);
data.wireEncode();
BOOST_CHECK_EQUAL(interest.matchesData(data), true);
@@ -224,6 +225,7 @@
Data data3 = data;
SignatureSha256WithRsa signature3(KeyLocator("ndn:/G")); // violates PublisherPublicKeyLocator
+ signature3.setValue(encoding::makeEmptyBlock(tlv::SignatureValue));
data3.setSignature(signature3);
data3.wireEncode();
BOOST_CHECK_EQUAL(interest.matchesData(data3), false);
@@ -234,6 +236,7 @@
Data data4 = data;
DigestSha256 signature4; // violates PublisherPublicKeyLocator
+ signature4.setValue(encoding::makeEmptyBlock(tlv::SignatureValue));
data4.setSignature(signature4);
data4.wireEncode();
BOOST_CHECK_EQUAL(interest.matchesData(data4), false);
@@ -260,7 +263,7 @@
data7.setName("ndn:/A/B");
data7.wireEncode();
- Interest interest7("/A/B/sha256digest=D548DECEFC4B880720DC9257A8D815E9DF4465E63742EE55C29133055DAA67C2");
+ Interest interest7("/A/B/sha256digest=54008e240a7eea2714a161dfddf0dd6ced223b3856e9da96792151e180f3b128");
BOOST_CHECK_EQUAL(interest7.matchesData(data7), true);
Interest interest7b("/A/B/sha256digest=0000000000000000000000000000000000000000000000000000000000000000");