~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to lib/cppunit-1.10.0/examples/cppunittest/OrthodoxTest.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef ORTHODOXTEST_H
 
2
#define ORTHODOXTEST_H
 
3
 
 
4
#include <cppunit/extensions/HelperMacros.h>
 
5
#include "MockTestListener.h"
 
6
 
 
7
 
 
8
class OrthodoxTest : public CPPUNIT_NS::TestFixture
 
9
{
 
10
  CPPUNIT_TEST_SUITE( OrthodoxTest );
 
11
  CPPUNIT_TEST( testValue );
 
12
  CPPUNIT_TEST( testValueBadConstructor );
 
13
  CPPUNIT_TEST( testValueBadInvert );
 
14
  CPPUNIT_TEST( testValueBadEqual );
 
15
  CPPUNIT_TEST( testValueBadNotEqual );
 
16
  CPPUNIT_TEST( testValueBadCall );
 
17
  CPPUNIT_TEST( testValueBadAssignment );
 
18
  CPPUNIT_TEST_SUITE_END();
 
19
 
 
20
public:
 
21
  OrthodoxTest();
 
22
  virtual ~OrthodoxTest();
 
23
 
 
24
  virtual void setUp();
 
25
  virtual void tearDown();
 
26
 
 
27
  void testValue();
 
28
  void testValueBadConstructor();
 
29
  void testValueBadInvert();
 
30
  void testValueBadEqual();
 
31
  void testValueBadNotEqual();
 
32
  void testValueBadCall();
 
33
  void testValueBadAssignment();
 
34
 
 
35
private:
 
36
  class Value
 
37
  {
 
38
  public:
 
39
    Value( int value =0 ) : m_value( value ) {}
 
40
 
 
41
    Value& operator= ( const Value& v )
 
42
    {
 
43
      m_value = v.m_value;
 
44
      return *this;
 
45
    }
 
46
 
 
47
    bool operator ==( const Value &other ) const
 
48
    {
 
49
      return m_value == other.m_value;
 
50
    }
 
51
 
 
52
    bool operator !=( const Value &other )
 
53
    {
 
54
      return !( *this == other );
 
55
    }
 
56
 
 
57
    Value operator !()
 
58
    {
 
59
      return Value( -1 - m_value );
 
60
    }
 
61
 
 
62
  protected:
 
63
    int m_value;
 
64
  };
 
65
 
 
66
 
 
67
  class ValueBadConstructor : public Value
 
68
  {
 
69
  public:
 
70
    ValueBadConstructor()
 
71
    {
 
72
      static int serialNumber = 0;
 
73
      m_value = ++serialNumber;
 
74
    }
 
75
 
 
76
    ValueBadConstructor( int value ) : Value( value ) {}
 
77
 
 
78
    ValueBadConstructor operator !()
 
79
    {
 
80
      return ValueBadConstructor( -1 - m_value );
 
81
    }
 
82
  };
 
83
 
 
84
  
 
85
  class ValueBadInvert : public Value
 
86
  {
 
87
  public:
 
88
    ValueBadInvert( int value =0 ) : Value( value ) {}
 
89
 
 
90
    ValueBadInvert operator !()
 
91
    {
 
92
      return ValueBadInvert( 1 );
 
93
    }
 
94
  };
 
95
 
 
96
  
 
97
  class ValueBadEqual : public Value
 
98
  {
 
99
  public:
 
100
    ValueBadEqual( int value =0 ) : Value( value ) {}
 
101
 
 
102
    ValueBadEqual operator !()
 
103
    {
 
104
      return ValueBadEqual( -1 - m_value );
 
105
    }
 
106
 
 
107
    bool operator ==( const ValueBadEqual &other ) const
 
108
    {
 
109
      return m_value != other.m_value;
 
110
    }
 
111
  };
 
112
 
 
113
  
 
114
  class ValueBadNotEqual : public Value
 
115
  {
 
116
  public:
 
117
    ValueBadNotEqual( int value =0 ) : Value( value ) {}
 
118
 
 
119
    ValueBadNotEqual operator !()
 
120
    {
 
121
      return ValueBadNotEqual( -1 - m_value );
 
122
    }
 
123
 
 
124
    bool operator !=( const ValueBadNotEqual &other )
 
125
    {
 
126
      return m_value == other.m_value;
 
127
    }
 
128
  };
 
129
 
 
130
 
 
131
  class ValueBadCall : public Value
 
132
  {
 
133
  public:
 
134
    ValueBadCall( int value =0 ) : Value( value ) {}
 
135
 
 
136
    ValueBadCall( const ValueBadCall &other ) 
 
137
    {
 
138
      static int serialNumber = 0;
 
139
      m_value = ++serialNumber;
 
140
    }
 
141
 
 
142
    ValueBadCall operator !()
 
143
    {
 
144
      return ValueBadCall( -1 - m_value );
 
145
    }
 
146
  };
 
147
 
 
148
 
 
149
  class ValueBadAssignment: public Value
 
150
  {
 
151
  public:
 
152
    ValueBadAssignment( int value =0 ) : Value( value ) {}
 
153
 
 
154
    ValueBadAssignment operator !()
 
155
    {
 
156
      return ValueBadAssignment( -1 - m_value );
 
157
    }
 
158
 
 
159
    ValueBadAssignment &operator =( const ValueBadAssignment &other )
 
160
    {
 
161
      ++m_value;
 
162
      return *this;
 
163
    }
 
164
  };
 
165
 
 
166
 
 
167
 
 
168
  OrthodoxTest( const OrthodoxTest &copy );
 
169
  void operator =( const OrthodoxTest &copy );
 
170
 
 
171
private:
 
172
  CPPUNIT_NS::TestResult *m_result;
 
173
  MockTestListener *m_testListener;
 
174
};
 
175
 
 
176
 
 
177
 
 
178
#endif  // ORTHODOXTEST_H