summaryrefslogtreecommitdiffstats
path: root/test/base-netstring.cpp
blob: faa7eb56f7226fb3dad42e08b047f4166db0f821 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */

#include "base/netstring.hpp"
#include "base/fifo.hpp"
#include <BoostTestTargetConfig.h>

using namespace icinga;

BOOST_AUTO_TEST_SUITE(base_netstring)

BOOST_AUTO_TEST_CASE(netstring)
{
	FIFO::Ptr fifo = new FIFO();

	NetString::WriteStringToStream(fifo, "hello");

	String s;
	StreamReadContext src;
	BOOST_CHECK(NetString::ReadStringFromStream(fifo, &s, src) == StatusNewItem);
	BOOST_CHECK(s == "hello");

	fifo->Close();
}

BOOST_AUTO_TEST_SUITE_END()