Macros | Functions
ostream_handle_test.cc File Reference
#include "boost/test/unit_test.hpp"
#include "cetlib/ostream_handle.h"
#include <fstream>
#include <string>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (ostream_handle test)
 

Functions

 BOOST_AUTO_TEST_CASE (observer)
 
 BOOST_AUTO_TEST_CASE (owner)
 
 BOOST_AUTO_TEST_CASE (observerThenOwner)
 
 BOOST_AUTO_TEST_CASE (ownerThenObserver)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (ostream_handle test)

Definition at line 1 of file ostream_handle_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( observer  )

Definition at line 26 of file ostream_handle_test.cc.

27 {
28  std::ostringstream oss;
29  ostream_handle obs{oss};
30  obs << "a";
31  BOOST_TEST(oss.str() == "a"s);
32 }
static QCString * s
Definition: config.cpp:1042
BOOST_AUTO_TEST_CASE ( owner  )

Definition at line 34 of file ostream_handle_test.cc.

35 {
36  std::string const fileName{"owner.txt"};
37  {
39  BOOST_TEST(static_cast<bool>(own));
40  own << "a";
41  }
42  BOOST_TEST(file_contents(fileName) == "a"s);
43 }
std::string string
Definition: nybbler.cc:12
fileName
Definition: dumpTree.py:9
static QCString * s
Definition: config.cpp:1042
BOOST_AUTO_TEST_CASE ( observerThenOwner  )

Definition at line 45 of file ostream_handle_test.cc.

46 {
47  std::string const fileName{"observerThenOwner.txt"};
48  {
49  std::ostringstream oss;
50  ostream_handle os{oss};
51  os << "a";
53  own << "b";
54  os = std::move(own);
55  os << "c";
56  }
57  BOOST_TEST(file_contents(fileName) == "bc"s);
58 }
std::string string
Definition: nybbler.cc:12
fileName
Definition: dumpTree.py:9
def move(depos, offset)
Definition: depos.py:107
static QCString * s
Definition: config.cpp:1042
BOOST_AUTO_TEST_CASE ( ownerThenObserver  )

Definition at line 60 of file ostream_handle_test.cc.

61 {
62  std::string const fileName{"ownerThenObserver.txt"};
63  {
65  os << "a";
66  std::ostringstream oss;
67  ostream_handle obs{oss};
68  obs << "b";
69  os = std::move(obs);
70  os << "c";
71  BOOST_TEST(oss.str() == "bc"s);
72  }
73  BOOST_TEST(file_contents(fileName) == "a"s);
74 }
std::string string
Definition: nybbler.cc:12
fileName
Definition: dumpTree.py:9
def move(depos, offset)
Definition: depos.py:107
static QCString * s
Definition: config.cpp:1042