1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "base/stdiostream.hpp"
4 #include "base/string.hpp"
5 #include <BoostTestTargetConfig.h>
8 using namespace icinga;
10 BOOST_AUTO_TEST_SUITE(base_stream)
12 BOOST_AUTO_TEST_CASE(readline_stdio)
14 std::stringstream msgbuf;
15 msgbuf << "Hello\nWorld\n\n";
17 StdioStream::Ptr stdstream = new StdioStream(&msgbuf, false);
19 StreamReadContext rlc;
22 BOOST_CHECK(stdstream->ReadLine(&line, rlc) == StatusNewItem);
23 BOOST_CHECK(line == "Hello");
25 BOOST_CHECK(stdstream->ReadLine(&line, rlc) == StatusNewItem);
26 BOOST_CHECK(line == "World");
28 BOOST_CHECK(stdstream->ReadLine(&line, rlc) == StatusNewItem);
29 BOOST_CHECK(line == "");
31 BOOST_CHECK(stdstream->ReadLine(&line, rlc) == StatusNewItem);
32 BOOST_CHECK(line == "");
34 BOOST_CHECK(stdstream->ReadLine(&line, rlc) == StatusEof);
39 BOOST_AUTO_TEST_SUITE_END()