File: teestream_test.cc

package info (click to toggle)
apt 3.1.13
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 22,764 kB
  • sloc: cpp: 71,085; sh: 31,750; xml: 5,553; perl: 217; python: 197; ansic: 191; makefile: 41
file content (39 lines) | stat: -rw-r--r-- 1,177 bytes parent folder | download | duplicates (3)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <config.h>

#include "../interactive-helper/teestream.h"
#include <fstream>
#include <sstream>
#include <string>

#include "common.h"

TEST(TeeStreamTest,TwoStringSinks)
{
   std::ostringstream one, two;
   basic_teeostream<char> tee(one, two);
   tee << "This is the " << 1 << '.' << " Test, we expect: " << std::boolalpha << true << "\n";
   std::string okay("This is the 1. Test, we expect: true\n");
   EXPECT_EQ(okay, one.str());
   EXPECT_EQ(okay, two.str());
   EXPECT_EQ(one.str(), two.str());
}

TEST(TeeStreamTest,DevNullSink1)
{
   std::ostringstream one;
   std::fstream two("/dev/null");
   basic_teeostream<char> tee(one, two);
   tee << "This is the " << 2 << '.' << " Test, we expect: " << std::boolalpha << false << "\n";
   std::string okay("This is the 2. Test, we expect: false\n");
   EXPECT_EQ(okay, one.str());
}

TEST(TeeStreamTest,DevNullSink2)
{
   std::ostringstream one;
   std::fstream two("/dev/null");
   basic_teeostream<char> tee(two, one);
   tee << "This is the " << 3 << '.' << " Test, we expect: " << std::boolalpha << false << "\n";
   std::string okay("This is the 3. Test, we expect: false\n");
   EXPECT_EQ(okay, one.str());
}