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.

86 lines
2.3KB

  1. // ---
  2. //
  3. // $Id: cpptest-textoutput.h,v 1.3 2005/06/08 08:08:06 nilu Exp $
  4. //
  5. // CppTest - A C++ Unit Testing Framework
  6. // Copyright (c) 2003 Niklas Lundell
  7. //
  8. // ---
  9. //
  10. // This library is free software; you can redistribute it and/or
  11. // modify it under the terms of the GNU Lesser General Public
  12. // License as published by the Free Software Foundation; either
  13. // version 2 of the License, or (at your option) any later version.
  14. //
  15. // This library is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. // Lesser General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU Lesser General Public
  21. // License along with this library; if not, write to the
  22. // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. // Boston, MA 02111-1307, USA.
  24. //
  25. // ---
  26. /** \file */
  27. #ifndef CPPTEST_TEXTOUTPUT_H
  28. #define CPPTEST_TEXTOUTPUT_H
  29. #include "cpptest-source.h"
  30. #include "cpptest-output.h"
  31. namespace Test
  32. {
  33. /// \brief Text output handler that outputs to the a stream.
  34. ///
  35. /// %Test suite output handler that writes its information as text to a
  36. /// a stream. It it possible to select between two different operational
  37. /// modes that controls the detail level, see Mode.
  38. ///
  39. class TextOutput : public Output
  40. {
  41. public:
  42. /// Output mode.
  43. ///
  44. enum Mode
  45. {
  46. /// Terse output mode, which only shows the number of correct tests.
  47. ///
  48. Terse,
  49. /// Verbose output mode, which also shows extended assert
  50. /// information for each test that failed.
  51. ///
  52. Verbose
  53. };
  54. TextOutput(Mode mode, std::ostream& stream = std::cout);
  55. virtual void finished(int tests, const Time& time);
  56. virtual void suite_start(int tests, const std::string& name);
  57. virtual void suite_end(int tests, const std::string& name,
  58. const Time& time);
  59. virtual void test_end(const std::string& name, bool ok,
  60. const Time& time);
  61. virtual void assertment(const Source& s);
  62. private:
  63. typedef std::list<Source> ErrorList;
  64. Mode _mode;
  65. std::ostream& _stream;
  66. ErrorList _suite_error_list;
  67. std::string _suite_name;
  68. int _suite_errors;
  69. int _suite_tests;
  70. int _suite_total_tests;
  71. int _total_errors;
  72. };
  73. } // namespace Test
  74. #endif // #ifndef CPPTEST_TEXTOUTPUT_H