tests: use decorators to label test data generators
Also various minor cleanups
Change-Id: Iaee434991b923abdf464293fec35da22d6cb449a
diff --git a/tests/unit/util/io.t.cpp b/tests/unit/util/io.t.cpp
index 3492fa1..2dc303d 100644
--- a/tests/unit/util/io.t.cpp
+++ b/tests/unit/util/io.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -34,22 +34,22 @@
struct NoEncoding
{
- const io::IoEncoding encoding{io::NO_ENCODING};
- const std::vector<uint8_t> blob{0xd1, 0x0, 0xb0, 0x1a};
+ static constexpr io::IoEncoding encoding = io::NO_ENCODING;
+ static inline const std::vector<uint8_t> blob{0xd1, 0x0, 0xb0, 0x1a};
std::istringstream stream{std::string("\xd1\x00\xb0\x1a", 4), std::ios_base::binary};
};
struct Base64Encoding
{
- const io::IoEncoding encoding = io::BASE64;
- const std::vector<uint8_t> blob{0x42, 0x61, 0x73, 0x65, 0x36, 0x34, 0x45, 0x6e, 0x63};
+ static constexpr io::IoEncoding encoding = io::BASE64;
+ static inline const std::vector<uint8_t> blob{0x42, 0x61, 0x73, 0x65, 0x36, 0x34, 0x45, 0x6e, 0x63};
std::istringstream stream{"QmFzZTY0RW5j\n", std::ios_base::binary};
};
struct HexEncoding
{
- const io::IoEncoding encoding = io::HEX;
- const std::vector<uint8_t> blob{0x48, 0x65, 0x78, 0x45, 0x6e, 0x63};
+ static constexpr io::IoEncoding encoding = io::HEX;
+ static inline const std::vector<uint8_t> blob{0x48, 0x65, 0x78, 0x45, 0x6e, 0x63};
std::istringstream stream{"486578456E63", std::ios_base::binary};
};
@@ -58,15 +58,15 @@
BOOST_AUTO_TEST_CASE_TEMPLATE(LoadBuffer, T, Encodings)
{
T t;
- shared_ptr<Buffer> buf = io::loadBuffer(t.stream, t.encoding);
- BOOST_CHECK_EQUAL_COLLECTIONS(buf->begin(), buf->end(), t.blob.begin(), t.blob.end());
+ shared_ptr<Buffer> buf = io::loadBuffer(t.stream, T::encoding);
+ BOOST_CHECK_EQUAL_COLLECTIONS(buf->begin(), buf->end(), T::blob.begin(), T::blob.end());
}
BOOST_AUTO_TEST_CASE_TEMPLATE(SaveBuffer, T, Encodings)
{
T t;
std::ostringstream os(std::ios_base::binary);
- io::saveBuffer(t.blob, os, t.encoding);
+ io::saveBuffer(T::blob, os, T::encoding);
BOOST_CHECK_EQUAL(os.str(), t.stream.str());
}