blob: 2ce633fc6f657de01baecd20f9eceec39740ed0d [file] [log] [blame]
Yingdi Yu3168c302015-07-04 16:45:40 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento74daf742018-11-23 18:14:13 -05002/*
3 * Copyright (c) 2013-2018 Regents of the University of California.
Yingdi Yu3168c302015-07-04 16:45:40 -07004 *
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/bool-sink.hpp"
23
24#include "boost-test.hpp"
25
26namespace ndn {
27namespace security {
28namespace transform {
29namespace tests {
30
31BOOST_AUTO_TEST_SUITE(Security)
32BOOST_AUTO_TEST_SUITE(Transform)
33BOOST_AUTO_TEST_SUITE(TestBoolSink)
34
35BOOST_AUTO_TEST_CASE(Basic)
36{
37 uint8_t in1[] = {0x00, 0x01};
38 bool value1 = true;
39 BoolSink sink1(value1);
40 BOOST_CHECK_EQUAL(sink1.write(in1, 1), 1);
41 BOOST_CHECK_EQUAL(sink1.write(in1 + 1, 1), 1);
42 sink1.end();
43 BOOST_CHECK_EQUAL(value1, false);
44 BOOST_CHECK_THROW(sink1.write(in1 + 1, 1), transform::Error);
45
46 uint8_t in2[] = {0x01, 0x00};
47 bool value2 = false;
48 BoolSink sink2(value2);
49 BOOST_CHECK_EQUAL(sink2.write(in2, 1), 1);
50 BOOST_CHECK_EQUAL(sink2.write(in2 + 1, 1), 1);
51 sink2.end();
52 BOOST_CHECK_EQUAL(value2, true);
53 BOOST_CHECK_THROW(sink2.write(in2 + 1, 1), transform::Error);
54}
55
56BOOST_AUTO_TEST_SUITE_END() // TestBoolSink
57BOOST_AUTO_TEST_SUITE_END() // Transform
58BOOST_AUTO_TEST_SUITE_END() // Security
59
60} // namespace tests
61} // namespace transform
62} // namespace security
63} // namespace ndn