Yingdi Yu | 3168c30 | 2015-07-04 16:45:40 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 74daf74 | 2018-11-23 18:14:13 -0500 | [diff] [blame^] | 2 | /* |
| 3 | * Copyright (c) 2013-2018 Regents of the University of California. |
Yingdi Yu | 3168c30 | 2015-07-04 16:45:40 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 6 | * |
| 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. |
| 20 | */ |
| 21 | |
| 22 | #include "security/transform/stream-sink.hpp" |
| 23 | |
| 24 | #include "boost-test.hpp" |
| 25 | |
| 26 | namespace ndn { |
| 27 | namespace security { |
| 28 | namespace transform { |
| 29 | namespace tests { |
| 30 | |
| 31 | BOOST_AUTO_TEST_SUITE(Security) |
| 32 | BOOST_AUTO_TEST_SUITE(Transform) |
| 33 | BOOST_AUTO_TEST_SUITE(TestStreamSink) |
| 34 | |
| 35 | BOOST_AUTO_TEST_CASE(Basic) |
| 36 | { |
| 37 | uint8_t in[] = { |
| 38 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 39 | 0x20, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f |
| 40 | }; |
| 41 | std::ostringstream os; |
| 42 | StreamSink sink(os); |
| 43 | BOOST_CHECK_EQUAL(sink.write(in, 4), 4); |
| 44 | BOOST_CHECK_EQUAL(sink.write(in + 4, 4), 4); |
| 45 | BOOST_CHECK_EQUAL(sink.write(in + 8, 4), 4); |
| 46 | BOOST_CHECK_EQUAL(sink.write(in + 12, 4), 4); |
| 47 | sink.end(); |
| 48 | std::string out = os.str(); |
| 49 | BOOST_CHECK_EQUAL_COLLECTIONS(in, in + sizeof(in), out.begin(), out.end()); |
| 50 | BOOST_CHECK_THROW(sink.write(in + 8, 8), transform::Error); |
| 51 | } |
| 52 | |
| 53 | BOOST_AUTO_TEST_SUITE_END() // TestStreamSink |
| 54 | BOOST_AUTO_TEST_SUITE_END() // Transform |
| 55 | BOOST_AUTO_TEST_SUITE_END() // Security |
| 56 | |
| 57 | } // namespace tests |
| 58 | } // namespace transform |
| 59 | } // namespace security |
| 60 | } // namespace ndn |