encoding: convert to span
Change-Id: I8bd73284fbd5acc0ff8ad2626af9b4324e9df7a1
diff --git a/tests/unit/lp/cache-policy.t.cpp b/tests/unit/lp/cache-policy.t.cpp
index 78c1548..8b27a6c 100644
--- a/tests/unit/lp/cache-policy.t.cpp
+++ b/tests/unit/lp/cache-policy.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).
*
@@ -38,10 +38,10 @@
policy.setPolicy(CachePolicyType::NO_CACHE);
Block wire;
- BOOST_REQUIRE_NO_THROW(wire = policy.wireEncode());
+ BOOST_CHECK_NO_THROW(wire = policy.wireEncode());
// Sample encoded value obtained with:
- // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+ // for (auto it = wire.begin(); it != wire.end(); ++it) {
// printf("0x%02x, ", *it);
// }
@@ -53,40 +53,31 @@
BOOST_CHECK_EQUAL_COLLECTIONS(expectedBlock, expectedBlock + sizeof(expectedBlock),
wire.begin(), wire.end());
- BOOST_REQUIRE_NO_THROW(policy.wireDecode(wire));
+ BOOST_CHECK_NO_THROW(policy.wireDecode(wire));
}
BOOST_AUTO_TEST_CASE(DecodeUnknownPolicyError)
{
- static const uint8_t expectedBlock[] = {
- 0xfd, 0x03, 0x34, 0x08, 0xfd, 0x03, 0x35, 0x04, 0xff, 0xff, 0xff, 0xff
- };
+ const Block wire({0xfd, 0x03, 0x34, 0x08, 0xfd, 0x03, 0x35, 0x04, 0x1f, 0xff, 0xff, 0xff});
CachePolicy policy;
- Block wire(expectedBlock, sizeof(expectedBlock));
- BOOST_REQUIRE_THROW(policy.wireDecode(wire), CachePolicy::Error);
+ BOOST_CHECK_THROW(policy.wireDecode(wire), CachePolicy::Error);
}
BOOST_AUTO_TEST_CASE(DecodeMissingPolicyError)
{
- static const uint8_t inputBlock[] = {
- 0xfd, 0x03, 0x34, 0x00
- };
+ const Block wire({0xfd, 0x03, 0x34, 0x00});
CachePolicy policy;
- Block wire(inputBlock, sizeof(inputBlock));
- BOOST_REQUIRE_THROW(policy.wireDecode(wire), CachePolicy::Error);
+ BOOST_CHECK_THROW(policy.wireDecode(wire), CachePolicy::Error);
}
BOOST_AUTO_TEST_CASE(DecodeInvalidPolicyError)
{
- static const uint8_t inputBlock[] = {
- 0xfd, 0x03, 0x34, 0x05, 0xfd, 0x03, 0x35, 0x01, 0x00
- };
+ const Block wire({0xfd, 0x03, 0x34, 0x05, 0xfd, 0x03, 0x35, 0x01, 0x00});
CachePolicy policy;
- Block wire(inputBlock, sizeof(inputBlock));
- BOOST_REQUIRE_THROW(policy.wireDecode(wire), CachePolicy::Error);
+ BOOST_CHECK_THROW(policy.wireDecode(wire), CachePolicy::Error);
}
BOOST_AUTO_TEST_CASE(Policy)
diff --git a/tests/unit/lp/nack-header.t.cpp b/tests/unit/lp/nack-header.t.cpp
index 4670608..c914eb0 100644
--- a/tests/unit/lp/nack-header.t.cpp
+++ b/tests/unit/lp/nack-header.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).
*
@@ -50,10 +50,10 @@
header.setReason(NackReason::DUPLICATE);
Block wire;
- BOOST_REQUIRE_NO_THROW(wire = header.wireEncode());
+ BOOST_CHECK_NO_THROW(wire = header.wireEncode());
// Sample encoded value obtained with:
- // for (Buffer::const_iterator it = wire.begin(); it != wire.end(); ++it) {
+ // for (auto it = wire.begin(); it != wire.end(); ++it) {
// printf("0x%02x, ", *it);
// }
@@ -65,20 +65,20 @@
BOOST_CHECK_EQUAL_COLLECTIONS(expectedBlock, expectedBlock + sizeof(expectedBlock),
wire.begin(), wire.end());
- BOOST_REQUIRE_NO_THROW(header.wireDecode(wire));
+ BOOST_CHECK_NO_THROW(header.wireDecode(wire));
}
BOOST_AUTO_TEST_CASE(DecodeUnknownReasonCode)
{
static const uint8_t expectedBlock[] = {
- 0xfd, 0x03, 0x20, 0x08, 0xfd, 0x03, 0x21, 0x04, 0xff, 0xff, 0xff, 0xff,
+ 0xfd, 0x03, 0x20, 0x08, 0xfd, 0x03, 0x21, 0x04, 0x1f, 0xff, 0xff, 0xff,
};
NackHeader header;
- Block wire(expectedBlock, sizeof(expectedBlock));
- BOOST_REQUIRE_NO_THROW(header.wireDecode(wire));
+ Block wire(expectedBlock);
+ BOOST_CHECK_NO_THROW(header.wireDecode(wire));
Block wireEncoded;
- BOOST_REQUIRE_NO_THROW(wireEncoded = header.wireEncode());
+ BOOST_CHECK_NO_THROW(wireEncoded = header.wireEncode());
BOOST_CHECK_EQUAL_COLLECTIONS(expectedBlock, expectedBlock + sizeof(expectedBlock),
wireEncoded.begin(), wireEncoded.end());
BOOST_CHECK_EQUAL(header.getReason(), NackReason::NONE);
@@ -91,10 +91,10 @@
};
NackHeader header;
- Block wire(expectedBlock, sizeof(expectedBlock));
- BOOST_REQUIRE_NO_THROW(header.wireDecode(wire));
+ Block wire(expectedBlock);
+ BOOST_CHECK_NO_THROW(header.wireDecode(wire));
Block wireEncoded;
- BOOST_REQUIRE_NO_THROW(wireEncoded = header.wireEncode());
+ BOOST_CHECK_NO_THROW(wireEncoded = header.wireEncode());
BOOST_CHECK_EQUAL_COLLECTIONS(expectedBlock, expectedBlock + sizeof(expectedBlock),
wireEncoded.begin(), wireEncoded.end());
BOOST_CHECK_EQUAL(header.getReason(), NackReason::NONE);
diff --git a/tests/unit/lp/packet.t.cpp b/tests/unit/lp/packet.t.cpp
index 5f750c3..7763f06 100644
--- a/tests/unit/lp/packet.t.cpp
+++ b/tests/unit/lp/packet.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-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -197,7 +197,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
packet.wireDecode(wire);
BOOST_CHECK_EQUAL(packet.count<FragIndexField>(), 1);
@@ -231,7 +231,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
packet.wireDecode(wire);
BOOST_CHECK_EQUAL(0, packet.count<FragmentField>());
BOOST_CHECK_EQUAL(1, packet.count<FragIndexField>());
@@ -249,7 +249,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
packet.wireDecode(wire);
BOOST_CHECK_EQUAL(1, packet.count<FragmentField>());
BOOST_CHECK_EQUAL(0, packet.count<FragIndexField>());
@@ -268,7 +268,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
packet.wireDecode(wire);
BOOST_CHECK_EQUAL(true, packet.has<NonDiscoveryField>());
packet.get<NonDiscoveryField>();
@@ -281,7 +281,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
packet.wireDecode(wire);
BOOST_CHECK_EQUAL(0, packet.count<FragmentField>());
BOOST_CHECK_EQUAL(0, packet.count<FragIndexField>());
@@ -299,7 +299,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
BOOST_CHECK_THROW(packet.wireDecode(wire), Packet::Error);
}
@@ -314,7 +314,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
BOOST_CHECK_THROW(packet.wireDecode(wire), Packet::Error);
}
@@ -331,7 +331,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
BOOST_CHECK_THROW(packet.wireDecode(wire), Packet::Error);
}
@@ -348,7 +348,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
BOOST_CHECK_THROW(packet.wireDecode(wire), Packet::Error);
}
@@ -365,7 +365,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
packet.wireDecode(wire);
BOOST_CHECK_EQUAL(1, packet.count<FragmentField>());
BOOST_CHECK_EQUAL(1, packet.count<FragIndexField>());
@@ -384,7 +384,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
BOOST_CHECK_THROW(packet.wireDecode(wire), Packet::Error);
}
@@ -399,7 +399,7 @@
};
Packet packet;
- Block wire(inputBlock, sizeof(inputBlock));
+ Block wire(inputBlock);
packet.wireDecode(wire);
BOOST_CHECK_EQUAL(1, packet.count<FragmentField>());
@@ -423,7 +423,7 @@
BOOST_AUTO_TEST_CASE(DecodeUnrecognizedTlvType)
{
Packet packet;
- Block wire = encoding::makeEmptyBlock(ndn::tlv::Name);
+ Block wire = makeEmptyBlock(ndn::tlv::Name);
BOOST_CHECK_THROW(packet.wireDecode(wire), Packet::Error);
}