You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
1.2 KiB

  1. #include <config.h>
  2. #include <string>
  3. #include <sstream>
  4. #include <fstream>
  5. #include "../interactive-helper/teestream.h"
  6. #include <gtest/gtest.h>
  7. TEST(TeeStreamTest,TwoStringSinks)
  8. {
  9. std::ostringstream one, two;
  10. basic_teeostream<char> tee(one, two);
  11. tee << "This is the " << 1 << '.' << " Test, we expect: " << std::boolalpha << true << "\n";
  12. std::string okay("This is the 1. Test, we expect: true\n");
  13. EXPECT_EQ(okay, one.str());
  14. EXPECT_EQ(okay, two.str());
  15. EXPECT_EQ(one.str(), two.str());
  16. }
  17. TEST(TeeStreamTest,DevNullSink1)
  18. {
  19. std::ostringstream one;
  20. std::fstream two("/dev/null");
  21. basic_teeostream<char> tee(one, two);
  22. tee << "This is the " << 2 << '.' << " Test, we expect: " << std::boolalpha << false << "\n";
  23. std::string okay("This is the 2. Test, we expect: false\n");
  24. EXPECT_EQ(okay, one.str());
  25. }
  26. TEST(TeeStreamTest,DevNullSink2)
  27. {
  28. std::ostringstream one;
  29. std::fstream two("/dev/null");
  30. basic_teeostream<char> tee(two, one);
  31. tee << "This is the " << 3 << '.' << " Test, we expect: " << std::boolalpha << false << "\n";
  32. std::string okay("This is the 3. Test, we expect: false\n");
  33. EXPECT_EQ(okay, one.str());
  34. }