Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | a84f464 | 2017-08-23 16:14:51 -0400 | [diff] [blame] | 2 | /* |
Davide Pesavento | 923ba44 | 2019-02-12 22:00:38 -0500 | [diff] [blame] | 3 | * Copyright (c) 2013-2019 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 20 | */ |
| 21 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 22 | #include "ndn-cxx/util/io.hpp" |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 23 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 24 | #include "tests/boost-test.hpp" |
| 25 | #include "tests/identity-management-fixture.hpp" |
Davide Pesavento | a84f464 | 2017-08-23 16:14:51 -0400 | [diff] [blame] | 26 | |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 27 | #include <boost/filesystem.hpp> |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 28 | #include <boost/mpl/vector.hpp> |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 29 | |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 30 | namespace ndn { |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 31 | namespace tests { |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 32 | |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 33 | BOOST_AUTO_TEST_SUITE(Util) |
| 34 | BOOST_AUTO_TEST_SUITE(TestIo) |
| 35 | |
| 36 | struct NoEncoding |
| 37 | { |
| 38 | const io::IoEncoding encoding{io::NO_ENCODING}; |
| 39 | const std::vector<uint8_t> blob{0xd1, 0x0, 0xb0, 0x1a}; |
| 40 | std::istringstream stream{std::string("\xd1\x00\xb0\x1a", 4), std::ios_base::binary}; |
| 41 | }; |
| 42 | |
| 43 | struct Base64Encoding |
| 44 | { |
| 45 | const io::IoEncoding encoding = io::BASE64; |
| 46 | const std::vector<uint8_t> blob{0x42, 0x61, 0x73, 0x65, 0x36, 0x34, 0x45, 0x6e, 0x63}; |
| 47 | std::istringstream stream{"QmFzZTY0RW5j\n", std::ios_base::binary}; |
| 48 | }; |
| 49 | |
| 50 | struct HexEncoding |
| 51 | { |
| 52 | const io::IoEncoding encoding = io::HEX; |
| 53 | const std::vector<uint8_t> blob{0x48, 0x65, 0x78, 0x45, 0x6e, 0x63}; |
| 54 | std::istringstream stream{"486578456E63", std::ios_base::binary}; |
| 55 | }; |
| 56 | |
| 57 | using Encodings = boost::mpl::vector<NoEncoding, Base64Encoding, HexEncoding>; |
| 58 | |
| 59 | BOOST_AUTO_TEST_CASE_TEMPLATE(LoadBuffer, T, Encodings) |
| 60 | { |
| 61 | T t; |
| 62 | shared_ptr<Buffer> buf = io::loadBuffer(t.stream, t.encoding); |
| 63 | BOOST_CHECK_EQUAL_COLLECTIONS(buf->begin(), buf->end(), t.blob.begin(), t.blob.end()); |
| 64 | } |
| 65 | |
| 66 | BOOST_AUTO_TEST_CASE_TEMPLATE(SaveBuffer, T, Encodings) |
| 67 | { |
| 68 | T t; |
| 69 | std::ostringstream os(std::ios_base::binary); |
| 70 | io::saveBuffer(t.blob.data(), t.blob.size(), os, t.encoding); |
| 71 | BOOST_CHECK_EQUAL(os.str(), t.stream.str()); |
| 72 | } |
| 73 | |
| 74 | BOOST_AUTO_TEST_CASE(LoadBufferException) |
| 75 | { |
| 76 | std::ifstream in("this-file-does-not-exist", std::ios_base::binary); |
| 77 | BOOST_CHECK_THROW(io::loadBuffer(in, io::NO_ENCODING), io::Error); |
| 78 | } |
| 79 | |
| 80 | BOOST_AUTO_TEST_CASE(SaveBufferException) |
| 81 | { |
| 82 | class NullStreambuf : public std::streambuf |
| 83 | { |
| 84 | }; |
| 85 | |
| 86 | NullStreambuf nullbuf; |
| 87 | std::ostream out(&nullbuf); |
| 88 | const Buffer buffer(1); |
| 89 | BOOST_CHECK_THROW(io::saveBuffer(buffer.data(), buffer.size(), out, io::NO_ENCODING), io::Error); |
| 90 | } |
| 91 | |
| 92 | BOOST_AUTO_TEST_CASE(UnknownIoEncoding) |
| 93 | { |
| 94 | std::stringstream ss; |
| 95 | BOOST_CHECK_THROW(io::loadBuffer(ss, static_cast<io::IoEncoding>(5)), std::invalid_argument); |
| 96 | BOOST_CHECK_THROW(io::saveBuffer(nullptr, 0, ss, static_cast<io::IoEncoding>(5)), std::invalid_argument); |
| 97 | } |
| 98 | |
| 99 | class FileIoFixture |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 100 | { |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 101 | protected: |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 102 | FileIoFixture() |
| 103 | : filepath(boost::filesystem::path(UNIT_TEST_CONFIG_PATH) / "TestIo") |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 104 | , filename(filepath.string()) |
| 105 | { |
| 106 | boost::filesystem::create_directories(filepath.parent_path()); |
| 107 | } |
| 108 | |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 109 | ~FileIoFixture() |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 110 | { |
| 111 | boost::system::error_code ec; |
| 112 | boost::filesystem::remove(filepath, ec); // ignore error |
| 113 | } |
| 114 | |
| 115 | /** \brief create a directory at filename, so that it's neither readable nor writable as a file |
| 116 | */ |
| 117 | void |
| 118 | mkdir() const |
| 119 | { |
| 120 | boost::filesystem::create_directory(filepath); |
| 121 | } |
| 122 | |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 123 | template<typename Container> |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 124 | Container |
| 125 | readFile() const |
| 126 | { |
| 127 | Container container; |
| 128 | std::ifstream fs(filename, std::ios_base::binary); |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 129 | BOOST_REQUIRE_MESSAGE(fs, "error opening file"); |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 130 | char ch; |
| 131 | while (fs.get(ch)) { |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 132 | container.push_back(static_cast<typename Container::value_type>(ch)); |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 133 | } |
| 134 | return container; |
| 135 | } |
| 136 | |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 137 | template<typename Container> |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 138 | void |
| 139 | writeFile(const Container& content) const |
| 140 | { |
| 141 | std::ofstream fs(filename, std::ios_base::binary); |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 142 | BOOST_REQUIRE_MESSAGE(fs, "error opening file"); |
| 143 | for (auto ch : content) { |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 144 | fs.put(static_cast<char>(ch)); |
| 145 | } |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 146 | BOOST_REQUIRE_MESSAGE(fs, "error writing file"); |
| 147 | } |
| 148 | |
| 149 | protected: |
| 150 | const boost::filesystem::path filepath; |
| 151 | const std::string filename; |
| 152 | }; |
| 153 | |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 154 | BOOST_FIXTURE_TEST_SUITE(FileIo, FileIoFixture) |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 155 | |
| 156 | class EncodableType |
| 157 | { |
| 158 | public: |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 159 | Block |
| 160 | wireEncode() const |
| 161 | { |
| 162 | if (shouldThrow) { |
Davide Pesavento | 923ba44 | 2019-02-12 22:00:38 -0500 | [diff] [blame] | 163 | NDN_THROW(tlv::Error("encode error")); |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | // block will be 0xAA, 0x01, 0xDD |
| 167 | return makeNonNegativeIntegerBlock(0xAA, 0xDD); |
| 168 | } |
| 169 | |
| 170 | public: |
| 171 | bool shouldThrow = false; |
| 172 | }; |
| 173 | |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 174 | template<bool SHOULD_THROW> |
Junxiao Shi | 435bb55 | 2016-09-04 03:14:47 +0000 | [diff] [blame] | 175 | class DecodableTypeTpl |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 176 | { |
| 177 | public: |
Junxiao Shi | 435bb55 | 2016-09-04 03:14:47 +0000 | [diff] [blame] | 178 | DecodableTypeTpl() = default; |
| 179 | |
| 180 | explicit |
| 181 | DecodableTypeTpl(const Block& block) |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 182 | { |
Junxiao Shi | 435bb55 | 2016-09-04 03:14:47 +0000 | [diff] [blame] | 183 | this->wireDecode(block); |
| 184 | } |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 185 | |
| 186 | void |
Junxiao Shi | 435bb55 | 2016-09-04 03:14:47 +0000 | [diff] [blame] | 187 | wireDecode(const Block& block) |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 188 | { |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 189 | if (SHOULD_THROW) { |
Davide Pesavento | 923ba44 | 2019-02-12 22:00:38 -0500 | [diff] [blame] | 190 | NDN_THROW(tlv::Error("decode error")); |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | // block must be 0xBB, 0x01, 0xEE |
| 194 | BOOST_CHECK_EQUAL(block.type(), 0xBB); |
| 195 | BOOST_REQUIRE_EQUAL(block.value_size(), 1); |
| 196 | BOOST_CHECK_EQUAL(block.value()[0], 0xEE); |
| 197 | } |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 198 | }; |
| 199 | |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 200 | using DecodableType = DecodableTypeTpl<false>; |
| 201 | using DecodableTypeThrow = DecodableTypeTpl<true>; |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 202 | |
| 203 | BOOST_AUTO_TEST_CASE(LoadNoEncoding) |
| 204 | { |
| 205 | this->writeFile<std::vector<uint8_t>>({0xBB, 0x01, 0xEE}); |
| 206 | shared_ptr<DecodableType> decoded = io::load<DecodableType>(filename, io::NO_ENCODING); |
| 207 | BOOST_CHECK(decoded != nullptr); |
| 208 | } |
| 209 | |
| 210 | BOOST_AUTO_TEST_CASE(LoadBase64) |
| 211 | { |
| 212 | this->writeFile<std::string>("uwHu\n"); // printf '\xBB\x01\xEE' | base64 |
Junxiao Shi | 4ce0bcf | 2016-09-03 07:09:03 +0000 | [diff] [blame] | 213 | shared_ptr<DecodableType> decoded = io::load<DecodableType>(filename, io::BASE64); |
| 214 | BOOST_CHECK(decoded != nullptr); |
| 215 | } |
| 216 | |
| 217 | BOOST_AUTO_TEST_CASE(LoadBase64Newline64) |
| 218 | { |
| 219 | this->writeFile<std::string>( |
| 220 | "CEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" |
| 221 | "AAAAAAAAAAAA\n"); |
| 222 | // printf '\x08\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 |
| 223 | // \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 |
| 224 | // \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 |
| 225 | // \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | base64 |
| 226 | shared_ptr<name::Component> decoded = io::load<name::Component>(filename, io::BASE64); |
| 227 | BOOST_CHECK(decoded != nullptr); |
| 228 | } |
| 229 | |
| 230 | BOOST_AUTO_TEST_CASE(LoadBase64Newline32) |
| 231 | { |
| 232 | this->writeFile<std::string>( |
| 233 | "CEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" |
| 234 | "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n" |
| 235 | "AAAAAAAAAAAA\n"); |
| 236 | shared_ptr<name::Component> decoded = io::load<name::Component>(filename, io::BASE64); |
| 237 | BOOST_CHECK(decoded != nullptr); |
| 238 | } |
| 239 | |
| 240 | BOOST_AUTO_TEST_CASE(LoadBase64NewlineEnd) |
| 241 | { |
| 242 | this->writeFile<std::string>( |
| 243 | "CEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"); |
| 244 | shared_ptr<name::Component> decoded = io::load<name::Component>(filename, io::BASE64); |
| 245 | BOOST_CHECK(decoded != nullptr); |
| 246 | } |
| 247 | |
| 248 | BOOST_AUTO_TEST_CASE(LoadBase64NoNewline) |
| 249 | { |
| 250 | this->writeFile<std::string>( |
| 251 | "CEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); |
| 252 | shared_ptr<name::Component> decoded = io::load<name::Component>(filename, io::BASE64); |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 253 | BOOST_CHECK(decoded != nullptr); |
| 254 | } |
| 255 | |
| 256 | BOOST_AUTO_TEST_CASE(LoadHex) |
| 257 | { |
| 258 | this->writeFile<std::string>("BB01EE"); |
| 259 | shared_ptr<DecodableType> decoded = io::load<DecodableType>(filename, io::HEX); |
| 260 | BOOST_CHECK(decoded != nullptr); |
| 261 | } |
| 262 | |
| 263 | BOOST_AUTO_TEST_CASE(LoadException) |
| 264 | { |
| 265 | this->writeFile<std::vector<uint8_t>>({0xBB, 0x01, 0xEE}); |
| 266 | shared_ptr<DecodableTypeThrow> decoded; |
| 267 | BOOST_CHECK_NO_THROW(decoded = io::load<DecodableTypeThrow>(filename, io::NO_ENCODING)); |
| 268 | BOOST_CHECK(decoded == nullptr); |
| 269 | } |
| 270 | |
| 271 | BOOST_AUTO_TEST_CASE(LoadNotHex) |
| 272 | { |
| 273 | this->writeFile<std::string>("not-hex"); |
| 274 | shared_ptr<DecodableType> decoded; |
| 275 | BOOST_CHECK_NO_THROW(decoded = io::load<DecodableType>(filename, io::HEX)); |
| 276 | BOOST_CHECK(decoded == nullptr); |
| 277 | } |
| 278 | |
| 279 | BOOST_AUTO_TEST_CASE(LoadFileNotReadable) |
| 280 | { |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 281 | shared_ptr<DecodableType> decoded; |
| 282 | BOOST_CHECK_NO_THROW(decoded = io::load<DecodableType>(filename, io::NO_ENCODING)); |
| 283 | BOOST_CHECK(decoded == nullptr); |
| 284 | } |
| 285 | |
| 286 | BOOST_AUTO_TEST_CASE(SaveNoEncoding) |
| 287 | { |
| 288 | EncodableType encoded; |
| 289 | BOOST_CHECK_NO_THROW(io::save(encoded, filename, io::NO_ENCODING)); |
| 290 | auto content = this->readFile<std::vector<uint8_t>>(); |
| 291 | uint8_t expected[] = {0xAA, 0x01, 0xDD}; |
| 292 | BOOST_CHECK_EQUAL_COLLECTIONS(content.begin(), content.end(), |
| 293 | expected, expected + sizeof(expected)); |
| 294 | } |
| 295 | |
| 296 | BOOST_AUTO_TEST_CASE(SaveBase64) |
| 297 | { |
| 298 | EncodableType encoded; |
Junxiao Shi | 4ce0bcf | 2016-09-03 07:09:03 +0000 | [diff] [blame] | 299 | BOOST_CHECK_NO_THROW(io::save(encoded, filename, io::BASE64)); |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 300 | auto content = this->readFile<std::string>(); |
| 301 | BOOST_CHECK_EQUAL(content, "qgHd\n"); // printf '\xAA\x01\xDD' | base64 |
| 302 | } |
| 303 | |
| 304 | BOOST_AUTO_TEST_CASE(SaveHex) |
| 305 | { |
| 306 | EncodableType encoded; |
| 307 | BOOST_CHECK_NO_THROW(io::save(encoded, filename, io::HEX)); |
| 308 | auto content = this->readFile<std::string>(); |
| 309 | BOOST_CHECK_EQUAL(content, "AA01DD"); |
| 310 | } |
| 311 | |
| 312 | BOOST_AUTO_TEST_CASE(SaveException) |
| 313 | { |
| 314 | EncodableType encoded; |
| 315 | encoded.shouldThrow = true; |
| 316 | BOOST_CHECK_THROW(io::save(encoded, filename, io::NO_ENCODING), io::Error); |
| 317 | } |
| 318 | |
| 319 | BOOST_AUTO_TEST_CASE(SaveFileNotWritable) |
| 320 | { |
| 321 | this->mkdir(); |
| 322 | EncodableType encoded; |
| 323 | encoded.shouldThrow = true; |
| 324 | BOOST_CHECK_THROW(io::save(encoded, filename, io::NO_ENCODING), io::Error); |
| 325 | } |
| 326 | |
Davide Pesavento | 6c6e385 | 2019-08-05 20:20:35 -0400 | [diff] [blame] | 327 | BOOST_AUTO_TEST_SUITE_END() // FileIo |
| 328 | |
| 329 | class IdCertFixture : public FileIoFixture |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 330 | , public IdentityManagementFixture |
| 331 | { |
| 332 | }; |
| 333 | |
| 334 | BOOST_FIXTURE_TEST_CASE(IdCert, IdCertFixture) |
| 335 | { |
Alexander Afanasyev | 70244f4 | 2017-01-04 12:47:12 -0800 | [diff] [blame] | 336 | auto identity = addIdentity("/TestIo/IdCert", RsaKeyParams()); |
| 337 | const auto& cert = identity.getDefaultKey().getDefaultCertificate(); |
| 338 | io::save(cert, filename); |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 339 | |
Alexander Afanasyev | 70244f4 | 2017-01-04 12:47:12 -0800 | [diff] [blame] | 340 | auto readCert = io::load<security::v2::Certificate>(filename); |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 341 | |
Junxiao Shi | 4ce0bcf | 2016-09-03 07:09:03 +0000 | [diff] [blame] | 342 | BOOST_REQUIRE(readCert != nullptr); |
Alexander Afanasyev | 70244f4 | 2017-01-04 12:47:12 -0800 | [diff] [blame] | 343 | BOOST_CHECK_EQUAL(cert.getName(), readCert->getName()); |
Ashlesh Gawande | e84d1eb | 2018-01-04 20:46:44 -0600 | [diff] [blame] | 344 | |
| 345 | this->writeFile<std::string>(""); |
| 346 | readCert = io::load<security::v2::Certificate>(filename); |
| 347 | BOOST_REQUIRE(readCert == nullptr); |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 348 | } |
| 349 | |
Junxiao Shi | c177988 | 2016-08-17 01:59:23 +0000 | [diff] [blame] | 350 | BOOST_AUTO_TEST_SUITE_END() // TestIo |
| 351 | BOOST_AUTO_TEST_SUITE_END() // Util |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 352 | |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 353 | } // namespace tests |
Yingdi Yu | f50098d | 2014-02-26 14:26:29 -0800 | [diff] [blame] | 354 | } // namespace ndn |