libStatGen Software  1
UnitTest.h
1 /*
2  * Copyright (C) 2011 Regents of the University of Michigan
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __UNITTEST_H
19 #define __UNITTEST_H
20 
21 #include <string>
22 #include <iostream>
23 
24 class UnitTest
25 {
26 protected:
27  std::string m_title;
28  int m_failures;
29  int m_testNum;
30 
31 public:
32  UnitTest(const char *title) : m_title(title), m_failures(0), m_testNum(0) {;};
33  void test();
34  int getPassCount() {return m_testNum - m_failures;}
35  int getFailureCount() {return m_failures;}
36  const std::string getTitle() const {return m_title;}
37 };
38 
39 std::ostream &operator << (std::ostream &stream, UnitTest &test)
40 {
41  stream << test.getTitle() << " PASS: " << test.getPassCount() <<
42  " FAIL: " << test.getFailureCount() << std::endl;
43  return stream;
44 }
45 
46 #endif
UnitTest
Definition: MemoryMapArrayTest.h:20
operator<<
InputFile & operator<<(InputFile &stream, const std::string &str)
Write to a file using streaming.
Definition: InputFile.h:736