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.

103 lines
2.4KB

  1. // ---
  2. //
  3. // $Id: cpptest-collectoroutput.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_COLLECTOROUTPUT_H
  28. #define CPPTEST_COLLECTOROUTPUT_H
  29. #include "cpptest-output.h"
  30. #include "cpptest-source.h"
  31. #include "cpptest-time.h"
  32. namespace Test
  33. {
  34. /// \brief Collector output.
  35. ///
  36. /// Base class for output handlers that need to report status when all
  37. /// tests have executed.
  38. ///
  39. class CollectorOutput : public Output
  40. {
  41. public:
  42. virtual void finished(int tests, const Time& time);
  43. virtual void suite_start(int tests, const std::string& name);
  44. virtual void suite_end(int tests, const std::string& name,
  45. const Time& time);
  46. virtual void test_start(const std::string& name);
  47. virtual void test_end(const std::string& name, bool ok,
  48. const Time& time);
  49. virtual void assertment(const Source& s);
  50. protected:
  51. struct OutputSuiteInfo;
  52. struct OutputTestInfo;
  53. struct OutputErrorTestInfo;
  54. typedef std::list<Source> Sources;
  55. struct TestInfo
  56. {
  57. std::string _name;
  58. Time _time;
  59. bool _success : 1;
  60. Sources _sources;
  61. explicit TestInfo(const std::string name);
  62. };
  63. typedef std::vector<TestInfo> Tests;
  64. struct SuiteInfo
  65. {
  66. std::string _name;
  67. int _errors;
  68. Tests _tests;
  69. Time _time;
  70. SuiteInfo(const std::string& name, int tests);
  71. };
  72. typedef std::list<SuiteInfo> Suites;
  73. Suites _suites;
  74. int _total_errors;
  75. int _total_tests;
  76. Time _total_time;
  77. CollectorOutput();
  78. private:
  79. SuiteInfo* _cur_suite;
  80. TestInfo* _cur_test;
  81. };
  82. } // namespace Test
  83. #endif // #ifndef CPPTEST_COLLECTOROUTPUT_H