encoding: convert to span
Change-Id: I8bd73284fbd5acc0ff8ad2626af9b4324e9df7a1
diff --git a/tests/unit/mgmt/control-response.t.cpp b/tests/unit/mgmt/control-response.t.cpp
index 74b1b03..c23f7f0 100644
--- a/tests/unit/mgmt/control-response.t.cpp
+++ b/tests/unit/mgmt/control-response.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-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -48,7 +48,7 @@
BOOST_AUTO_TEST_CASE(Decode)
{
- ControlResponse cr(Block(WIRE, sizeof(WIRE)));
+ ControlResponse cr(Block{WIRE});
BOOST_CHECK_EQUAL(cr.getCode(), 404);
BOOST_CHECK_EQUAL(cr.getText(), "Nothing not found");
}
diff --git a/tests/unit/mgmt/dispatcher.t.cpp b/tests/unit/mgmt/dispatcher.t.cpp
index 7827516..30b5853 100644
--- a/tests/unit/mgmt/dispatcher.t.cpp
+++ b/tests/unit/mgmt/dispatcher.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -245,7 +245,7 @@
Block
wireEncode() const final
{
- return Block();
+ return {};
}
void
@@ -298,8 +298,7 @@
BOOST_AUTO_TEST_CASE(StatusDataset)
{
- const uint8_t smallBuf[] = {0x81, 0x01, 0x01};
- const Block smallBlock(smallBuf, sizeof(smallBuf));
+ const Block smallBlock({0x81, 0x01, 0x01});
const Block largeBlock = [] {
Block b(129, std::make_shared<const Buffer>(3000));
b.encode();
@@ -399,10 +398,10 @@
content = [&dataInStorage] () -> Block {
EncodingBuffer encoder;
- size_t valueLength = encoder.prependByteArray(dataInStorage[1].getContent().value(),
- dataInStorage[1].getContent().value_size());
- valueLength += encoder.prependByteArray(dataInStorage[0].getContent().value(),
- dataInStorage[0].getContent().value_size());
+ size_t valueLength = encoder.prependBytes({dataInStorage[1].getContent().value(),
+ dataInStorage[1].getContent().value_size()});
+ valueLength += encoder.prependBytes({dataInStorage[0].getContent().value(),
+ dataInStorage[0].getContent().value_size()});
encoder.prependVarNumber(valueLength);
encoder.prependVarNumber(tlv::Content);
return encoder.block();
@@ -427,8 +426,7 @@
BOOST_AUTO_TEST_CASE(NotificationStream)
{
- const uint8_t buf[] = {0x82, 0x01, 0x02};
- const Block block(buf, sizeof(buf));
+ const Block block({0x82, 0x01, 0x02});
auto post = dispatcher.addNotificationStream("test");
post(block);
diff --git a/tests/unit/mgmt/nfd/status-dataset.t.cpp b/tests/unit/mgmt/nfd/status-dataset.t.cpp
index 21fb288..2c8c7f7 100644
--- a/tests/unit/mgmt/nfd/status-dataset.t.cpp
+++ b/tests/unit/mgmt/nfd/status-dataset.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -70,12 +70,12 @@
BOOST_CONCEPT_ASSERT((WireEncodable<T1>));
BOOST_CONCEPT_ASSERT((WireEncodable<T2>));
- ndn::encoding::EncodingBuffer buffer;
+ EncodingBuffer buffer;
payload2.wireEncode(buffer);
payload1.wireEncode(buffer);
auto data = this->prepareDatasetReply(prefix);
- data->setContent(buffer.buf(), buffer.size());
+ data->setContent(buffer);
face.receive(*signData(data));
}
diff --git a/tests/unit/mgmt/status-dataset-context.t.cpp b/tests/unit/mgmt/status-dataset-context.t.cpp
index 6d1e0b9..4192337 100644
--- a/tests/unit/mgmt/status-dataset-context.t.cpp
+++ b/tests/unit/mgmt/status-dataset-context.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -67,7 +67,7 @@
size_t valueLength = 0;
for (const auto& args : sendDataHistory) {
const auto& content = args.content;
- valueLength += encoder.appendByteArray(content.value(), content.value_size());
+ valueLength += encoder.appendBytes({content.value(), content.value_size()});
}
encoder.prependVarNumber(valueLength);
encoder.prependVarNumber(tlv::Content);
@@ -237,7 +237,7 @@
BOOST_AUTO_TEST_CASE(AppendReject)
{
const uint8_t buf[] = {0x82, 0x01, 0x02};
- BOOST_CHECK_NO_THROW(context.append(Block(buf, sizeof(buf))));
+ BOOST_CHECK_NO_THROW(context.append(Block(buf)));
BOOST_CHECK_EXCEPTION(context.reject(), std::logic_error, [] (const auto& e) {
return e.what() == "cannot call reject() after append/end"s;
});
@@ -246,7 +246,7 @@
BOOST_AUTO_TEST_CASE(AppendEndReject)
{
const uint8_t buf[] = {0x82, 0x01, 0x02};
- BOOST_CHECK_NO_THROW(context.append(Block(buf, sizeof(buf))));
+ BOOST_CHECK_NO_THROW(context.append(Block(buf)));
BOOST_CHECK_NO_THROW(context.end());
BOOST_CHECK_EXCEPTION(context.reject(), std::logic_error, [] (const auto& e) {
return e.what() == "cannot call reject() after append/end"s;
@@ -257,7 +257,7 @@
{
BOOST_CHECK_NO_THROW(context.end());
const uint8_t buf[] = {0x82, 0x01, 0x02};
- BOOST_CHECK_EXCEPTION(context.append(Block(buf, sizeof(buf))), std::logic_error, [] (const auto& e) {
+ BOOST_CHECK_EXCEPTION(context.append(Block(buf)), std::logic_error, [] (const auto& e) {
return e.what() == "cannot call append() on a finalized context"s;
});
}
@@ -282,7 +282,7 @@
{
BOOST_CHECK_NO_THROW(context.reject());
const uint8_t buf[] = {0x82, 0x01, 0x02};
- BOOST_CHECK_EXCEPTION(context.append(Block(buf, sizeof(buf))), std::logic_error, [] (const auto& e) {
+ BOOST_CHECK_EXCEPTION(context.append(Block(buf)), std::logic_error, [] (const auto& e) {
return e.what() == "cannot call append() on a finalized context"s;
});
}