]> git.saurik.com Git - apt.git/blame - test/libapt/teestream_test.cc
For ReMap to work, S has to be marked volatile :/.
[apt.git] / test / libapt / teestream_test.cc
CommitLineData
e1ae0531
DK
1#include <config.h>
2
3#include <string>
4#include <sstream>
5#include <fstream>
6#include "../interactive-helper/teestream.h"
7
8#include <gtest/gtest.h>
9
10TEST(TeeStreamTest,TwoStringSinks)
11{
12 std::ostringstream one, two;
13 basic_teeostream<char> tee(one, two);
14 tee << "This is the " << 1 << '.' << " Test, we expect: " << std::boolalpha << true << "\n";
15 std::string okay("This is the 1. Test, we expect: true\n");
16 EXPECT_EQ(okay, one.str());
17 EXPECT_EQ(okay, two.str());
18 EXPECT_EQ(one.str(), two.str());
19}
20
21TEST(TeeStreamTest,DevNullSink1)
22{
23 std::ostringstream one;
24 std::fstream two("/dev/null");
25 basic_teeostream<char> tee(one, two);
26 tee << "This is the " << 2 << '.' << " Test, we expect: " << std::boolalpha << false << "\n";
27 std::string okay("This is the 2. Test, we expect: false\n");
28 EXPECT_EQ(okay, one.str());
29}
30
31TEST(TeeStreamTest,DevNullSink2)
32{
33 std::ostringstream one;
34 std::fstream two("/dev/null");
35 basic_teeostream<char> tee(two, one);
36 tee << "This is the " << 3 << '.' << " Test, we expect: " << std::boolalpha << false << "\n";
37 std::string okay("This is the 3. Test, we expect: false\n");
38 EXPECT_EQ(okay, one.str());
39}