summaryrefslogtreecommitdiffstats
path: root/test/libapt/teestream_test.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 09:59:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 09:59:37 +0000
commit76e2632459410dec81337edb6a9fee33c9a660f3 (patch)
treea73345df208eede4a4daad340515c9328f34625c /test/libapt/teestream_test.cc
parentInitial commit. (diff)
downloadapt-76e2632459410dec81337edb6a9fee33c9a660f3.tar.xz
apt-76e2632459410dec81337edb6a9fee33c9a660f3.zip
Adding upstream version 2.7.12.upstream/2.7.12
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/libapt/teestream_test.cc')
-rw-r--r--test/libapt/teestream_test.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/libapt/teestream_test.cc b/test/libapt/teestream_test.cc
new file mode 100644
index 0000000..a897e08
--- /dev/null
+++ b/test/libapt/teestream_test.cc
@@ -0,0 +1,39 @@
+#include <config.h>
+
+#include "../interactive-helper/teestream.h"
+#include <fstream>
+#include <sstream>
+#include <string>
+
+#include <gtest/gtest.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());
+}