util: backport C++20 std::span and use it in various APIs
Implementation taken from span-lite by Martin Moene,
commit 337af6e23f6d3264136c16565546244da23159ba
Change-Id: Icfd0ba6841cbf6ef7870c31c881df940da9faf7e
diff --git a/tests/unit/security/transform/step-source.t.cpp b/tests/unit/security/transform/step-source.t.cpp
index d8aae47..0179011 100644
--- a/tests/unit/security/transform/step-source.t.cpp
+++ b/tests/unit/security/transform/step-source.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-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -58,17 +58,18 @@
"0123456701234567012345670123456701234567012345670123456701234567"
"0123456701234567012345670123456701234567012345670123456701234567"
"0123456701234567012345670123456701234567012345670123456701234567";
- const uint8_t* buf = reinterpret_cast<const uint8_t*>(input.data());
+ auto buf = reinterpret_cast<const uint8_t*>(input.data());
std::ostringstream os;
StepSource ss;
ss >> streamSink(os);
- BOOST_CHECK_EQUAL(ss.write(buf, 320), 320);
- BOOST_CHECK_EQUAL(ss.write(buf + 320, 320), 320);
- BOOST_CHECK_EQUAL(ss.write(buf + 640, 320), 320);
- BOOST_CHECK_EQUAL(ss.write(buf + 960, 320), 320);
+ BOOST_CHECK_EQUAL(ss.write({buf, 320}), 320);
+ BOOST_CHECK_EQUAL(ss.write({buf + 320, 320}), 320);
+ BOOST_CHECK_EQUAL(ss.write({buf + 640, 320}), 320);
+ BOOST_CHECK_EQUAL(ss.write({buf + 960, 320}), 320);
ss.end();
- BOOST_CHECK_THROW(ss.write(buf + 960, 320), transform::Error);
+
+ BOOST_CHECK_THROW(ss.write({buf + 960, 320}), transform::Error);
BOOST_CHECK_EQUAL(os.str(), input);
}
@@ -78,6 +79,7 @@
StepSource ss;
ss >> streamSink(os);
ss.end();
+
BOOST_CHECK_EQUAL(os.str(), "");
}