Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
StreamInserter.ut.cpp
Go to the documentation of this file.
1// The Reactive C++ Toolbox.
2// Copyright (C) 2022 Reactive Markets Limited
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#include "StreamInserter.hpp"
17
18#include <boost/test/unit_test.hpp>
19
20using namespace std;
21using namespace toolbox;
22
23namespace {
24auto start_tag(const char* s)
25{
26 return make_stream_inserter<ostream>([=](ostream& os) { os << '<' << s << '>'; });
27}
28auto end_tag(const char* s)
29{
30 return make_stream_inserter<ostream>([=](ostream& os) { os << "</" << s << '>'; });
31}
32} // namespace
33
35
37{
38 stringstream ss;
39 ss << start_tag("foo") << "bar" << end_tag("foo");
40 BOOST_CHECK_EQUAL(ss.str(), "<foo>bar</foo>"s);
41}
42
BOOST_CHECK_EQUAL(v.size(), 10U)
BOOST_AUTO_TEST_CASE(StreamInserterCase)
STL namespace.
constexpr auto bind() noexcept
Definition Slot.hpp:92