2 * The software in this package is distributed under the GNU General
3 * Public License version 2 (with a special exception described below).
5 * A copy of GNU General Public License (GPL) is included in this distribution,
6 * in the file COPYING.GPL.
8 * As a special exception, if other files instantiate templates or use macros
9 * or inline functions from this file, or you compile this file and link it
10 * with other works to produce a work based on this file, this file
11 * does not by itself cause the resulting work to be covered
12 * by the GNU General Public License.
14 * However the source code for this file must still be made available
15 * in accordance with section (3) of the GNU General Public License.
17 * This exception does not invalidate any other reasons why a work based
18 * on this file might be covered by the GNU General Public License.
22 * unit tests for the module "pipestream"
24 * Copyright 2018 by Intra2net AG
28 #define BOOST_TEST_DYN_LINK
29 #include <boost/test/unit_test.hpp>
30 #include <boost/algorithm/string/replace.hpp>
32 #include "stringfunc.hxx"
33 #include "pipestream.hxx"
35 #define TO_CHARP_TOK(x) #x
36 #define TO_CHARP(x) TO_CHARP_TOK(x)
38 BOOST_AUTO_TEST_SUITE(pipestream)
40 BOOST_AUTO_TEST_SUITE(read)
42 # define ENOUGH_ZEROS 42
43 const char *const zero_bytes_argv [] =
44 { "/usr/bin/head", "-c", TO_CHARP(ENOUGH_ZEROS), "/dev/zero", NULL };
46 BOOST_AUTO_TEST_CASE(abspath_zeros_shell_ok)
48 const std::string result =
49 capture_exec (I2n::join_string (zero_bytes_argv, " "));
51 BOOST_CHECK_EQUAL(result.size (), ENOUGH_ZEROS);
54 BOOST_AUTO_TEST_CASE(abspath_zeros_noshell_ok)
56 const std::string result = capture_exec (zero_bytes_argv);
58 BOOST_CHECK_EQUAL(result.size (), ENOUGH_ZEROS);
61 BOOST_AUTO_TEST_SUITE_END() /* [pipestream->read] */
63 BOOST_AUTO_TEST_SUITE_END() /* [pipestream] */