]>
Commit | Line | Data |
---|---|---|
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 | ||
10 | TEST(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 | ||
21 | TEST(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 | ||
31 | TEST(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 | } |