Class documentation of Concepts

Loading...
Searching...
No Matches
testsuite.hh
Go to the documentation of this file.
1
7#ifndef testSUITE_H
8#define testSUITE_H
9
10#include "testcase.hh"
11#include "exceptions.hh"
12#include <vector>
13using std::string;
14using std::ostream;
15using std::vector;
16
17namespace test {
18
19 // ******************************************************** TestSuiteError **
20
25 public:
26 TestSuiteError(const std::string& error) throw();
27 protected:
28 virtual std::ostream& info(std::ostream& os) const throw();
29 };
30
31 // ************************************************************* TestSuite **
32
41 class TestSuite {
42 public:
47 TestSuite(const string& name, ostream* osptr = 0);
48
50 string getName() const { return m_name; }
52 long getNumPassed() const;
54 long getNumFailed() const;
56 const ostream* getStream() const { return m_osptr; }
58 void setStream(ostream* osptr) { m_osptr = osptr; }
59
61 void addTest(TestCase* t);
63 void addSuite(const TestSuite&);
65 void run();
70 long report() const;
72 void free();
73 private:
74 string m_name;
75 ostream* m_osptr;
76 vector<TestCase*> m_tests;
77 void reset();
78
80 TestSuite(const TestSuite&);
82 TestSuite& operator=(const TestSuite&);
83 };
84
85 inline TestSuite::TestSuite(const string& name, ostream* osptr) :
86 m_name(name), m_osptr(osptr) {
87 if (m_osptr == 0)
88 m_osptr = &std::cout;
89 }
90
91} // namespace test
92
93#endif // testSUITE_H
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void run()
Runs all test cases in the suite.
const ostream * getStream() const
Returns output stream.
Definition testsuite.hh:56
void addSuite(const TestSuite &)
Adds a test suite to this test suite.
string getName() const
Returns name of test suite.
Definition testsuite.hh:50
long getNumPassed() const
Returns number of passed tests.
TestSuite(const string &name, ostream *osptr=0)
Definition testsuite.hh:85
void addTest(TestCase *t)
Adds a test case to the suite of tests.
long getNumFailed() const
Returns number of failed tests.
void free()
Deletes the tests.
void setStream(ostream *osptr)
Sets the output stream.
Definition testsuite.hh:58
long report() const