NDCTest.hh
Go to the documentation of this file.
1 #ifndef _NDCTEST_HH
2 #define _NDCTEST_HH
3 
4 #include <string>
5 #include "cppunit/TestCaller.h"
6 #include "cppunit/TestCase.h"
7 #include "cppunit/TestSuite.h"
8 #include <iostream>
9 
10 template<class NDCCLASS> class NDCTest : public CppUnit::TestCase {
11  protected:
12  NDCCLASS* _nDC;
13 
14  public:
15  NDCTest() {
16  }
17 
18  NDCTest(std::string name) : CppUnit::TestCase(name) {
19  }
20 
21  virtual void registerTests(CppUnit::TestSuite* suite) {
22  suite->addTest(new CppUnit::TestCaller<NDCTest>("testEmpty",
24  suite->addTest(new CppUnit::TestCaller<NDCTest>("testPush",
26  suite->addTest(new CppUnit::TestCaller<NDCTest>("testPush2",
28  suite->addTest(new CppUnit::TestCaller<NDCTest>("testPop",
30  suite->addTest(new CppUnit::TestCaller<NDCTest>("testClear",
32  }
33 
34  int countTestCases() const {
35  return 5;
36  }
37 
38  void setUp() {
39  _nDC = new NDCCLASS();
40  }
41 
42  void tearDown() {
43  delete _nDC;
44  }
45 
46  void testEmpty() {
47  assert(_nDC->_get() == "");
48  assert(_nDC->_getDepth() == 0);
49  }
50 
51  void testPush() {
52  _nDC->_push("push context 1");
53  assert(_nDC->_get() == "push context 1");
54  assert(_nDC->_getDepth() == 1);
55 
56  }
57 
58  void testPush2() {
59  _nDC->_push("push context 1");
60  _nDC->_push("push context 2");
61  assert(_nDC->_get() == "push context 1 push context 2");
62  assert(_nDC->_getDepth() == 2);
63 
64  }
65 
66  void testPop() {
67  _nDC->_push("push context 1");
68  _nDC->_push("push context 2");
69  _nDC->_pop();
70  assert(_nDC->_get() == "push context 1");
71  assert(_nDC->_getDepth() == 1);
72  }
73 
74  void testClear() {
75  _nDC->_push("push context 1");
76  _nDC->_push("push context 2");
77  _nDC->_clear();
78  assert(_nDC->_get() == "");
79  assert(_nDC->_getDepth() == 0);
80  }
81 };
82 
83 #endif // _NDCTEST_HH
int countTestCases() const
Definition: NDCTest.hh:34
NDCTest()
Definition: NDCTest.hh:15
void testPush2()
Definition: NDCTest.hh:58
void testClear()
Definition: NDCTest.hh:74
NDCTest(std::string name)
Definition: NDCTest.hh:18
NDCCLASS * _nDC
Definition: NDCTest.hh:12
void testEmpty()
Definition: NDCTest.hh:46
virtual void registerTests(CppUnit::TestSuite *suite)
Definition: NDCTest.hh:21
void tearDown()
Definition: NDCTest.hh:42
void testPush()
Definition: NDCTest.hh:51
void setUp()
Definition: NDCTest.hh:38
void testPop()
Definition: NDCTest.hh:66


log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:10:00