File: AtomBondIteratorTraits_test.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 239,848 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 93
file content (263 lines) | stat: -rw-r--r-- 7,003 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/CONCEPT/classTest.h>

///////////////////////////
#include <BALL/KERNEL/atom.h>
#include <BALL/KERNEL/bond.h>
#include <BALL/KERNEL/PTE.h>
#include <BALL/KERNEL/molecule.h>
#include <BALL/KERNEL/fragment.h>
#include <BALL/CONCEPT/textPersistenceManager.h>
///////////////////////////

START_TEST(Atom)

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

using namespace BALL;

Atom::BondIteratorTraits* bit_ptr = 0;
CHECK(Atom::BondIteratorTraits() throw())
	bit_ptr = new Atom::BondIteratorTraits;
	TEST_NOT_EQUAL(bit_ptr, 0)
RESULT

CHECK(Atom::~BondIteratorTraits() throw())
	delete bit_ptr;
RESULT

CHECK(Atom::BondIteratorTraits(const Atom& atom) throw())
	Atom atom;
	Atom::BondIteratorTraits bit(atom);
	TEST_EQUAL(&atom, bit.getContainer())
RESULT

CHECK(Atom::BondIteratorTraits(const Atom::BondIteratorTraits& traits, bool /* deep */ = true) throw())
	Atom atom;
	Atom::BondIteratorTraits bit1(atom);
	Atom::BondIteratorTraits bit2(bit1);
	TEST_EQUAL(bit1.getContainer(), bit2.getContainer())
	TEST_EQUAL((bit1 == bit2), true)
RESULT

CHECK(Atom::BondIteratorTraits& operator = (const Atom::BondIteratorTraits& traits) throw())
	Atom atom;
	Atom::BondIteratorTraits bit1(atom);
	Atom::BondIteratorTraits bit2 = bit1;
	TEST_EQUAL(bit1.getContainer(), bit2.getContainer())
	TEST_EQUAL((bit1 == bit2), true)
RESULT

CHECK(Atom* getContainer() throw())
	Atom::BondIteratorTraits bit;
	TEST_EQUAL(bit.getContainer(), 0)
	Atom atom;
	Atom::BondIteratorTraits bit2(atom);
	TEST_EQUAL(&atom, bit2.getContainer())
RESULT

CHECK(bool isSingular() const throw())
	Atom::BondIteratorTraits bit;
	TEST_EQUAL(bit.isSingular(), true)
	Atom atom;
	Atom::BondIteratorTraits bit2(atom);
	TEST_EQUAL(bit2.isSingular(), false)
RESULT

Atom atom_a;
Atom atom_b1;
Atom atom_b2;
Bond* bond_a_b1 = atom_a.createBond(atom_b1);
Bond* bond_a_b2 = atom_a.createBond(atom_b2);
const Bond& bond_a_b1_const_ref = *bond_a_b1;
const Bond& bond_a_b2_const_ref = *bond_a_b2;

CHECK(BondIteratorPosition_& getPosition() throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL(bit.getPosition(), 0)
	bit.forward();
	TEST_EQUAL(bit.getPosition(), 1)
RESULT

CHECK(const BondIteratorPosition_& getPosition() const throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL(bit.getPosition(), 0)
	bit.forward();
	TEST_EQUAL(bit.getPosition(), 1)
RESULT

CHECK(bool operator == (const Atom::BondIteratorTraits& traits) const throw())
	Atom::BondIteratorTraits bit1(atom_a);
	bit1.forward();
	Atom::BondIteratorTraits bit2;
	TEST_EQUAL((bit1 == bit2), false);
	Atom::BondIteratorTraits bit3(atom_a);
	TEST_EQUAL((bit1 == bit3), false);
	bit3.forward();
	TEST_EQUAL((bit1 == bit3), true);
RESULT

CHECK(bool operator != (const Atom::BondIteratorTraits& traits) const throw())
	Atom::BondIteratorTraits bit1(atom_a);
	bit1.forward();
	Atom::BondIteratorTraits bit2;
	TEST_EQUAL((bit1 != bit2), true);
	Atom::BondIteratorTraits bit3(atom_a);
	TEST_EQUAL((bit1 != bit3), true);
	bit3.forward();
	TEST_EQUAL((bit1 != bit3), false);
RESULT

CHECK(bool operator < (const Atom::BondIteratorTraits& traits) const throw())
	Atom::BondIteratorTraits bit1(atom_a);
	Atom::BondIteratorTraits bit2(atom_a);
	TEST_EQUAL((bit1 < bit2), false);
	bit2.forward();
	TEST_EQUAL((bit1 < bit2), true);
RESULT

CHECK(Distance getDistance(const Atom::BondIteratorTraits& traits) const throw())
	Atom::BondIteratorTraits bit1(atom_a);
	Atom::BondIteratorTraits bit2(atom_a);
	TEST_EQUAL(bit1.getDistance(bit2), 0)
	bit1.forward();
	TEST_EQUAL(bit1.getDistance(bit2), 1)
RESULT

CHECK(bool isValid() const throw())
	Atom::BondIteratorTraits bit1;
	TEST_EQUAL(bit1.isValid(), false)
	Atom::BondIteratorTraits bit2(atom_a);
	TEST_EQUAL(bit2.isValid(), true)
RESULT

CHECK(void invalidate() throw())
	Atom::BondIteratorTraits bit1;
	TEST_EQUAL(bit1.isValid(), false)
	Atom::BondIteratorTraits bit2(atom_a);
	TEST_EQUAL(bit2.isValid(), true)
	bit2.invalidate();
	TEST_EQUAL(bit2.isValid(), false)
RESULT

CHECK(void toBegin() throw())
	Atom::BondIteratorTraits bit(atom_a);
	bit.forward();
	bit.toBegin();
	TEST_EQUAL(bit.getPosition(), 0)
RESULT

CHECK(bool isBegin() const throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL(bit.isBegin(), true);
	bit.forward();
	TEST_EQUAL(bit.isBegin(), false);
RESULT

CHECK(void toEnd() throw())
	Atom::BondIteratorTraits bit(atom_a);
	bit.toEnd();
	TEST_EQUAL(bit.getPosition(), 2)
RESULT

CHECK(bool isEnd() const throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL(bit.isEnd(), false)
	bit.toEnd();
	TEST_EQUAL(bit.isEnd(), true)
RESULT

CHECK(Bond& getData() throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL(&bit.getData(), bond_a_b1)
	bit.forward();
	TEST_EQUAL(&bit.getData(), bond_a_b2)
RESULT
	
CHECK(const Bond& getData() const throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL((bit.getData() == bond_a_b1_const_ref), true);
	bit.forward();
	TEST_EQUAL((bit.getData() == bond_a_b2_const_ref), true);
RESULT

CHECK(void forward() throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL(bit.getPosition(), 0)
	bit.forward();
	TEST_EQUAL(bit.getPosition(), 1)
RESULT

CHECK(friend std::ostream& operator << (std::ostream& s, const Atom::BondIteratorTraits& traits) throw())
  // ???
RESULT

CHECK(void dump(std::ostream& s = std::cout, Size depth = 0) const throw())
  // ???
RESULT

CHECK(void toRBegin() throw())
	Atom::BondIteratorTraits bit(atom_a);
	bit.toRBegin();
	TEST_EQUAL(bit.getPosition(), 1);
RESULT

CHECK(void isRBegin() throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL(bit.isRBegin(), false)
	bit.toRBegin();
	TEST_EQUAL(bit.isRBegin(), true)
RESULT

CHECK(void toREnd() throw())
	Atom::BondIteratorTraits bit(atom_a);
	bit.toREnd();
	TEST_EQUAL(bit.getPosition(), -1)
RESULT

CHECK(bool isREnd() const throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL(bit.isREnd(), false)
	bit.toREnd();
	TEST_EQUAL(bit.isREnd(), true)
RESULT

CHECK(void backward() throw())
	Atom::BondIteratorTraits bit(atom_a);
	bit.backward();
	TEST_EQUAL(bit.getPosition(), -1)
RESULT

CHECK(void backward(Distance distance) throw())
	Atom::BondIteratorTraits bit(atom_a);
	bit.toEnd();
	bit.backward(2);
	TEST_EQUAL(bit.getPosition(), 0)
RESULT

CHECK(void forward(Distance distance) throw())
	Atom::BondIteratorTraits bit(atom_a);
	bit.forward(2);
	TEST_EQUAL(bit.getPosition(), 2)
RESULT

CHECK(Bond& getData(Index index) throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL(&bit.getData(0), bond_a_b1)
	TEST_EQUAL(&bit.getData(1), bond_a_b2)
RESULT

CHECK(const Bond& getData(Index index) const throw())
	Atom::BondIteratorTraits bit(atom_a);
	TEST_EQUAL((&bit.getData(0) == &bond_a_b1_const_ref), true)
	TEST_EQUAL((&bit.getData(1) == &bond_a_b2_const_ref), true)
RESULT

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

END_TEST