testStdIo.cxx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. #include <cm/string_view>
  4. #include <cmext/string_view>
  5. #include "cmStdIoInit.h"
  6. #include "cmStdIoStream.h"
  7. #include "testCommon.h"
  8. namespace {
  9. void printTermKind(cm::string_view t, cm::StdIo::Stream& s)
  10. {
  11. switch (s.Kind()) {
  12. case cm::StdIo::TermKind::None:
  13. std::cout << " " << t << " is not a terminal.\n";
  14. break;
  15. case cm::StdIo::TermKind::VT100:
  16. std::cout << " " << t << " is a VT100 terminal.\n";
  17. break;
  18. #ifdef _WIN32
  19. case cm::StdIo::TermKind::Console:
  20. std::cout << " " << t << " is a Windows Console.\n";
  21. break;
  22. #endif
  23. };
  24. }
  25. bool testStream()
  26. {
  27. std::cout << "testStream()\n";
  28. printTermKind("stdin"_s, cm::StdIo::In());
  29. printTermKind("stdout"_s, cm::StdIo::Out());
  30. printTermKind("stderr"_s, cm::StdIo::Err());
  31. return true;
  32. }
  33. }
  34. int testStdIo(int /*unused*/, char* /*unused*/[])
  35. {
  36. cm::StdIo::Init();
  37. return runTests({
  38. testStream,
  39. });
  40. }