File: Atom_test.C

package info (click to toggle)
ball 1.4.3~beta1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 318,984 kB
  • sloc: cpp: 346,579; ansic: 4,097; python: 2,664; yacc: 1,778; lex: 1,099; xml: 964; sh: 688; sql: 316; awk: 118; makefile: 108
file content (691 lines) | stat: -rw-r--r-- 20,028 bytes parent folder | download | duplicates (2)
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/CONCEPT/classTest.h>
#include <BALLTestConfig.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/KERNEL/residue.h>
#include <BALL/KERNEL/secondaryStructure.h>
#include <BALL/KERNEL/chain.h>
#include <BALL/CONCEPT/textPersistenceManager.h>

#include "ItemCollector.h"
///////////////////////////

START_TEST(Atom)

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

using namespace BALL;

Atom* atom = 0;
CHECK(Atom() throw())
	atom = new Atom;
	TEST_NOT_EQUAL(atom, 0)
RESULT

CHECK(void setCharge(float charge) throw())
	atom->setCharge(1.23456);
	TEST_REAL_EQUAL(atom->getCharge(), 1.23456);
RESULT

CHECK(float getCharge() const throw())
	Atom a;
	TEST_REAL_EQUAL(a.getCharge(), 0.0);
RESULT

const Atom ac;

CHECK(void setName(const String& name) throw())
	TEST_EQUAL(atom->getName(), "")
	atom->setName("ATOMNAME");
	TEST_EQUAL(atom->getName(), "ATOMNAME");
RESULT
			
CHECK(const String& getName() const throw())
	TEST_EQUAL(ac.getName(), BALL_ATOM_DEFAULT_NAME)
RESULT

CHECK(void setElement(const Element& element) throw())
	TEST_EQUAL(atom->getElement(), Element::UNKNOWN)
	atom->setElement(PTE.getElement(1));
	TEST_EQUAL(atom->getElement(), PTE.getElement(1))
RESULT
			
CHECK(const Element& getElement() const throw())
	TEST_EQUAL(ac.getElement(), *BALL_ATOM_DEFAULT_ELEMENT)
RESULT

Vector3	null_vector(0, 0, 0);
Vector3	test_vector(1, 2, 3);
CHECK(void setPosition(const Vector3& position) throw())
	TEST_EQUAL(atom->getPosition(), null_vector)
	atom->setPosition(test_vector);
	TEST_EQUAL(atom->getPosition(), test_vector)
RESULT

CHECK(const Vector3& getPosition() const throw())
	TEST_EQUAL(ac.getPosition(), Vector3(BALL_ATOM_DEFAULT_POSITION))
RESULT

CHECK(Vector3& getPosition() throw())
	Atom a;
	a.getPosition().set(1,2,3);
	TEST_EQUAL(a.getPosition(), Vector3(1,2,3))
RESULT

CHECK(float getDistance(const Vector3&) const)
	Atom a, b;
	a.getPosition().set(1,2,3);
	b.getPosition().set(0, 0, 0);
	TEST_REAL_EQUAL(a.getDistance(b), 3.741657387)
RESULT

CHECK(void setRadius(float radius) throw())
	TEST_REAL_EQUAL(atom->getRadius(), 0.0)
	atom->setRadius(1.23456);
	TEST_REAL_EQUAL(atom->getRadius(), 1.23456)
RESULT

CHECK(float getRadius() const throw())
	TEST_EQUAL(ac.getRadius(), BALL_ATOM_DEFAULT_RADIUS)
RESULT

CHECK(void setType(Type atom_type) throw())
	TEST_EQUAL(atom->getType(), Atom::UNKNOWN_TYPE)
	atom->setType(27);
	TEST_EQUAL(atom->getType(), 27);
RESULT
		
CHECK(Type getType() const throw())
	TEST_EQUAL(ac.getType(), BALL_ATOM_DEFAULT_TYPE)
RESULT

CHECK(void setVelocity(const Vector3& velocity) throw())
	TEST_EQUAL(atom->getVelocity(), null_vector)
	atom->setVelocity(test_vector);
	TEST_EQUAL(atom->getVelocity(), test_vector)
RESULT
			
CHECK(const Vector3& getVelocity() const throw())
	TEST_EQUAL(ac.getVelocity(), Vector3(BALL_ATOM_DEFAULT_VELOCITY))
RESULT

CHECK(void setForce(const Vector3& force) throw())
	TEST_EQUAL(atom->getForce(), null_vector)
	atom->setForce(test_vector);
	TEST_EQUAL(atom->getForce(), test_vector)
RESULT

CHECK(const Vector3& getForce() const throw())
	TEST_EQUAL(ac.getForce(), Vector3(BALL_ATOM_DEFAULT_FORCE))
RESULT

CHECK(Vector3& getForce() throw())
	Atom a;
	a.getForce() = Vector3(1,2,3);
	TEST_EQUAL(a.getForce(), Vector3(1,2,3))
RESULT

CHECK(Size countBonds() const throw())
	TEST_EQUAL(atom->countBonds(), 0)
RESULT

Atom* atom2 = 0;
CHECK(Atom(const Atom& atom, bool deep = true) throw())
	atom2 = new Atom(*atom);
	TEST_NOT_EQUAL(atom2, 0)
	TEST_EQUAL(atom2->getName(), atom->getName())
	TEST_REAL_EQUAL(atom2->getCharge(), atom->getCharge())
	TEST_REAL_EQUAL(atom2->getRadius(), atom->getRadius())
	TEST_EQUAL(atom2->getPosition(), atom->getPosition())
	TEST_EQUAL(atom2->getVelocity(), atom->getVelocity())
	TEST_EQUAL(atom2->getForce(), atom->getForce())
	TEST_EQUAL(atom2->getType(), atom->getType())
	TEST_EQUAL(atom2->countBonds(), atom->countBonds())
	TEST_NOT_EQUAL(atom2->getHandle(), atom->getHandle())
RESULT

CHECK(~Atom() throw())
	delete atom2;
RESULT
			
CHECK(Atom(Element& element, const String& name, const String& type_name = BALL_ATOM_DEFAULT_TYPE_NAME, Type atom_type = BALL_ATOM_DEFAULT_TYPE, const Vector3& position = Vector3(BALL_ATOM_DEFAULT_POSITION), const Vector3& velocity = Vector3(BALL_ATOM_DEFAULT_VELOCITY), const Vector3& force = Vector3(BALL_ATOM_DEFAULT_FORCE), float charge = BALL_ATOM_DEFAULT_CHARGE, float radius = BALL_ATOM_DEFAULT_RADIUS) throw())
	atom2 = new Atom(PTE[Element::HELIUM],
									 "TESTNAME",
									 "TESTTYPE",
									 12,
									 null_vector,
									 test_vector,
									 test_vector,
									 1.23456,
									 2.34567);
	TEST_NOT_EQUAL(atom2, 0)
	TEST_EQUAL(atom2->getElement(), PTE[Element::He])
	TEST_EQUAL(atom2->getName(), "TESTNAME")
	TEST_EQUAL(atom2->getType(), 12)
	TEST_EQUAL(atom2->getPosition(), null_vector)
	TEST_EQUAL(atom2->getVelocity(), test_vector)
	TEST_EQUAL(atom2->getForce(), test_vector)
	TEST_REAL_EQUAL(atom2->getCharge(), 1.23456)
	TEST_REAL_EQUAL(atom2->getRadius(), 2.34567)
RESULT


CHECK(void clear() throw())
	atom2->clear();
	TEST_EQUAL(atom2->getName(), "")
	TEST_EQUAL(atom2->getType(), Atom::UNKNOWN_TYPE)
	TEST_EQUAL(atom2->getElement(), Element::UNKNOWN)
	TEST_EQUAL(atom2->getPosition(), null_vector)
	TEST_EQUAL(atom2->getVelocity(), null_vector)
	TEST_EQUAL(atom2->getForce(), null_vector)
	TEST_REAL_EQUAL(atom2->getCharge(), 0.0)
	TEST_REAL_EQUAL(atom2->getRadius(), 0.0)
	TEST_EQUAL(atom2->countBonds(), 0)
	TEST_EQUAL(atom->countBonds(), 0)
RESULT

CHECK(BALL_CREATE_DEEP(Atom))
	delete atom2;
	atom2 = (Atom*)atom->create(false);
	TEST_NOT_EQUAL(atom2, 0)
	TEST_EQUAL(atom2->getName(), atom->getName())
	TEST_REAL_EQUAL(atom2->getCharge(), atom->getCharge())
	TEST_REAL_EQUAL(atom2->getRadius(), atom->getRadius())
	TEST_EQUAL(atom2->getPosition(), atom->getPosition())
	TEST_EQUAL(atom2->getVelocity(), atom->getVelocity())
	TEST_EQUAL(atom2->getForce(), atom->getForce())
	TEST_EQUAL(atom2->getType(), atom->getType())
	TEST_EQUAL(atom2->countBonds(), atom->countBonds())
	TEST_NOT_EQUAL(atom2->getHandle(), atom->getHandle())
	delete atom2;
	atom2 = (Atom*)atom->create(true);
	TEST_NOT_EQUAL(atom2, 0)
	TEST_EQUAL(atom2->getName(), atom->getName())
	TEST_REAL_EQUAL(atom2->getCharge(), atom->getCharge())
	TEST_REAL_EQUAL(atom2->getRadius(), atom->getRadius())
	TEST_EQUAL(atom2->getPosition(), atom->getPosition())
	TEST_EQUAL(atom2->getVelocity(), atom->getVelocity())
	TEST_EQUAL(atom2->getForce(), atom->getForce())
	TEST_EQUAL(atom2->getType(), atom->getType())
	TEST_EQUAL(atom2->countBonds(), atom->countBonds())
	TEST_NOT_EQUAL(atom2->getHandle(), atom->getHandle())
RESULT

CHECK(void destroy() throw())
	atom->createBond(*atom2);
	atom2->destroy();
	TEST_EQUAL(atom2->getName(), "")
	TEST_EQUAL(atom2->getType(), Atom::UNKNOWN_TYPE)
	TEST_EQUAL(atom2->getElement(), Element::UNKNOWN)
	TEST_EQUAL(atom2->getPosition(), null_vector)
	TEST_EQUAL(atom2->getVelocity(), null_vector)
	TEST_EQUAL(atom2->getForce(), null_vector)
	TEST_REAL_EQUAL(atom2->getCharge(), 0.0)
	TEST_REAL_EQUAL(atom2->getRadius(), 0.0)
	TEST_EQUAL(atom2->countBonds(), 0)
	TEST_EQUAL(atom->countBonds(), 0)
RESULT

CHECK(void set(const Atom& atom, bool deep = true) throw())
	atom2->set(*atom);
	TEST_NOT_EQUAL(atom2, 0)
	TEST_EQUAL(atom2->getName(), atom->getName())
	TEST_REAL_EQUAL(atom2->getCharge(), atom->getCharge())
	TEST_REAL_EQUAL(atom2->getRadius(), atom->getRadius())
	TEST_EQUAL(atom2->getPosition(), atom->getPosition())
	TEST_EQUAL(atom2->getVelocity(), atom->getVelocity())
	TEST_EQUAL(atom2->getForce(), atom->getForce())
	TEST_EQUAL(atom2->getType(), atom->getType())
	TEST_EQUAL(atom2->countBonds(), atom->countBonds())
	TEST_NOT_EQUAL(atom2->getHandle(), atom->getHandle())
RESULT

CHECK(Atom& operator = (const Atom& atom) throw())
	atom2->clear();
	*atom2 = *atom;
	TEST_NOT_EQUAL(atom2, 0)
	TEST_EQUAL(atom2->getName(), atom->getName())
	TEST_REAL_EQUAL(atom2->getCharge(), atom->getCharge())
	TEST_REAL_EQUAL(atom2->getRadius(), atom->getRadius())
	TEST_EQUAL(atom2->getPosition(), atom->getPosition())
	TEST_EQUAL(atom2->getVelocity(), atom->getVelocity())
	TEST_EQUAL(atom2->getForce(), atom->getForce())
	TEST_EQUAL(atom2->getType(), atom->getType())
	TEST_EQUAL(atom2->countBonds(), atom->countBonds())
	TEST_NOT_EQUAL(atom2->getHandle(), atom->getHandle())
RESULT

CHECK(void get(Atom& atom, bool deep = true) const throw())
	atom2->clear();
	atom2->get(*atom);
	TEST_NOT_EQUAL(atom2, 0)
	TEST_EQUAL(atom2->getName(), atom->getName())
	TEST_REAL_EQUAL(atom2->getCharge(), atom->getCharge())
	TEST_REAL_EQUAL(atom2->getRadius(), atom->getRadius())
	TEST_EQUAL(atom2->getPosition(), atom->getPosition())
	TEST_EQUAL(atom2->getVelocity(), atom->getVelocity())
	TEST_EQUAL(atom2->getForce(), atom->getForce())
	TEST_EQUAL(atom2->getType(), atom->getType())
	TEST_EQUAL(atom2->countBonds(), atom->countBonds())
	TEST_NOT_EQUAL(atom2->getHandle(), atom->getHandle())
RESULT
delete atom2;
atom2 = 0;

Atom* atom3 = 0;
Atom* atom4 = 0;
CHECK(void swap(Atom& atom) throw())
	atom2 = new Atom(PTE[Element::LITHIUM],
												"TESTNAME2",
												"TESTTYPE2",
												23,
												test_vector,
												test_vector,
												null_vector,
												3.23456,
												4.34567);

	atom3 = new Atom(*atom);
	atom4 = new Atom(*atom2);
	atom3->swap(*atom4);
	TEST_EQUAL(atom4->getName(), atom->getName())
	TEST_REAL_EQUAL(atom4->getCharge(), atom->getCharge())
	TEST_REAL_EQUAL(atom4->getRadius(), atom->getRadius())
	TEST_EQUAL(atom4->getPosition(), atom->getPosition())
	TEST_EQUAL(atom4->getVelocity(), atom->getVelocity())
	TEST_EQUAL(atom4->getForce(), atom->getForce())
	TEST_EQUAL(atom4->getType(), atom->getType())
	TEST_EQUAL(atom4->countBonds(), atom->countBonds())
	TEST_EQUAL(atom3->getName(), atom2->getName())
	TEST_REAL_EQUAL(atom3->getCharge(), atom2->getCharge())
	TEST_REAL_EQUAL(atom3->getRadius(), atom2->getRadius())
	TEST_EQUAL(atom3->getPosition(), atom2->getPosition())
	TEST_EQUAL(atom3->getVelocity(), atom2->getVelocity())
	TEST_EQUAL(atom3->getForce(), atom2->getForce())
	TEST_EQUAL(atom3->getType(), atom2->getType())
	TEST_EQUAL(atom3->countBonds(), atom2->countBonds())	
	delete atom2;	
	atom2 = 0;
RESULT

Atom atomx;
const Atom& acx = atomx;
Molecule molecule;
Fragment fragment;
molecule.insert(fragment);
fragment.insert(atomx);
CHECK(const Fragment* getFragment() const throw())
	TEST_EQUAL((atomx.getFragment() == &fragment), true)
RESULT

CHECK(Fragment* getFragment() throw())
	atomx.getFragment()->setName("1234");
	TEST_EQUAL(fragment.getName(), "1234")
RESULT

CHECK(const Molecule* getMolecule() const throw())
	TEST_EQUAL(acx.getMolecule(), &molecule)
RESULT

CHECK(Molecule* getMolecule() throw())
	atomx.getMolecule()->setName("asdff");
	TEST_EQUAL(molecule.getName(), "asdff")
RESULT

Bond*	bond;
CHECK(Bond* createBond(Atom& atom) throw())
	atom->createBond(*atom3);
	atom3->getBond(*atom);
	TEST_EQUAL(atom->countBonds(), 1)
	TEST_EQUAL(atom3->countBonds(), 1)
	TEST_EQUAL(atom->getBond(*atom3), atom3->getBond(*atom))
	atom->createBond(*atom4);
	atom->createBond(*atom4);
	bond = atom->createBond(*atom);
	TEST_EQUAL(bond, 0);

	TEST_EQUAL(atom4->countBonds(), 1)
	TEST_EQUAL(atom->countBonds(), 2)
	TEST_EQUAL(atom->getBond(*atom4), atom4->getBond(*atom))
RESULT

CHECK(bool destroyBond(const Atom& atom) throw())
	atom->destroyBond(*atom4);
	TEST_EQUAL(atom->countBonds(), 1)
	TEST_EQUAL(atom4->countBonds(), 0)
	TEST_EQUAL(atom4->getBond(*atom), 0)
RESULT
bond = 0;
			
CHECK(void destroyBonds() throw())
	atom->createBond(*atom4);
	atom->destroyBonds();
	TEST_EQUAL(atom->countBonds(), 0)
	TEST_EQUAL(atom3->countBonds(), 0)
	TEST_EQUAL(atom4->countBonds(), 0)
RESULT

CHECK(bool hasBond(const Bond& bond) const throw())
	atom->createBond(*atom4);
	TEST_EQUAL(atom->hasBond(*atom->getBond(*atom3)), false)
	TEST_EQUAL(atom->hasBond(*atom->getBond(*atom4)), true)
	TEST_EQUAL(atom->hasBond(*atom->getBond(*atom)), false)
RESULT

CHECK(bool isBoundTo(const Atom& atom) const throw())
	TEST_EQUAL(atom->isBoundTo(*atom3), false)
	TEST_EQUAL(atom->isBoundTo(*atom4), true)
	TEST_EQUAL(atom->isBoundTo(*atom), false)
RESULT

CHECK(bool isBound() const throw())
	TEST_EQUAL(atom->isBound(), true)
	TEST_EQUAL(atom3->isBound(), false)
RESULT

CHECK(bool isValid() const throw())
	TEST_EQUAL(atom->isValid(), true)
RESULT

TextPersistenceManager pm;
atom->setForce(Vector3(1.0, 2.0, 3.0));
atom->setPosition(Vector3(2.0, 3.0, 4.0));
atom->setVelocity(Vector3(3.0, 4.0, 5.0));
atom->setName("TESTNAME");
atom->setCharge(1.23456);
atom->setRadius(2.34567);
String filename;
using std::ofstream;
using std::ios;
CHECK(void persistentWrite(PersistenceManager& pm, const char* name = 0) const throw(Exception::GeneralException))
	NEW_TMP_FILE(filename)
	ofstream	ofile(filename.c_str(), std::ios::out);
	pm.setOstream(ofile);
	using namespace RTTI;
	*atom >> pm;
	ofile.close();
RESULT

using std::ifstream;
using std::cout;
using namespace RTTI;
CHECK(void persistentRead(PersistenceManager& pm) throw(Exception::GeneralException))
	ifstream	ifile(filename.c_str());
	pm.setIstream(ifile);
	PersistentObject*	ptr = 0;
	ptr = pm.readObject();
	ifile.close();
	STATUS("PO ptr = " << (void*)ptr)

	TEST_NOT_EQUAL(ptr, 0)
	if (ptr != 0)
	{
        TEST_EQUAL(isKindOf<Atom>(ptr), true)
        if (isKindOf<Atom>(ptr))
		{
			Atom* pers_atom = castTo<Atom>(*ptr);
			TEST_EQUAL(pers_atom->getName(), atom->getName())
			TEST_REAL_EQUAL(pers_atom->getCharge(), atom->getCharge())
			TEST_REAL_EQUAL(pers_atom->getRadius(), atom->getRadius())
			TEST_EQUAL(pers_atom->getPosition(), atom->getPosition())
			TEST_EQUAL(pers_atom->getVelocity(), atom->getVelocity())
			TEST_EQUAL(pers_atom->getForce(), atom->getForce())
			TEST_EQUAL(pers_atom->getType(), atom->getType())
			TEST_EQUAL(pers_atom->countBonds(), atom->countBonds())
			TEST_NOT_EQUAL(pers_atom->getHandle(), atom->getHandle())
			delete pers_atom->getBond(0)->getPartner(*pers_atom);
		}
		delete ptr;
		ptr = 0;
	}
	ptr = 0;
RESULT
delete atom;
delete atom3;
delete atom4;

atom = 0;

CHECK(bool operator == (const Atom& atom) const throw())
	Atom a1;
	Atom a2;
	TEST_EQUAL(a1 == a2, false)
	a1 = a2;
	TEST_EQUAL(a1 == a2, false)

	TEST_EQUAL(a2 == a2, true)
RESULT

CHECK(bool operator != (const Atom& atom) const throw())
	Atom a1;
	Atom a2;
	TEST_EQUAL(a1 != a2, true)
	a1 = a2;
	TEST_EQUAL(a1 != a2, true)

	TEST_EQUAL(a2 != a2, false)
RESULT

CHECK([EXTRA] bond iteration)
	Atom* a1 = new Atom;
	Atom* a2 = new Atom;
	Atom* a3 = new Atom;
	Atom* a4 = new Atom;
	a1->createBond(*a2);
	a1->createBond(*a3);
	a1->createBond(*a4);
	TEST_EQUAL(a1->countBonds(), 3)
	TEST_EQUAL(a2->countBonds(), 1)
	TEST_EQUAL(a3->countBonds(), 1)
	TEST_EQUAL(a4->countBonds(), 1)
	ABORT_IF(a1->countBonds() != 3)
	
	Atom::BondIterator it(a1->beginBond());
	TEST_EQUAL(+it, true)
	TEST_EQUAL(&*it, a1->getBond(0))
	++it;
	TEST_EQUAL(+it, true)
	TEST_EQUAL(&*it, a1->getBond(1))
	++it;
	TEST_EQUAL(+it, true)	
	TEST_EQUAL(&*it, a1->getBond(2))
	++it;
	TEST_EQUAL(+it, false)	
	TEST_EQUAL(it == a1->endBond(), true)

	delete a1;
	delete a2;
	delete a3;
	delete a4;

	// Empty iteration
	a1 = new Atom;
	it = a1->beginBond();
	TEST_EQUAL(+it, false)
	TEST_EQUAL(it == a1->endBond(), true)
	delete a1;
RESULT

CHECK(Bond* cloneBond(Bond& bond, Atom& atom) throw())
	Atom a, b, c;
	Bond bond("",a,b);
	TEST_EQUAL(a.cloneBond(bond, b), &bond)
	Bond* bond2 = a.cloneBond(bond,c);
	TEST_EQUAL(bond2 != 0, true)
	TEST_EQUAL(a.countBonds(), 2)
RESULT

CHECK(Bond* createBond(Bond& bond, Atom& atom) throw())
	Atom a,b,c;
	Bond bond;
	TEST_EQUAL(a.createBond(bond, a), 0)
	TEST_EQUAL(a.countBonds(), 0)
	TEST_EQUAL(a.createBond(bond, b), &bond)
	TEST_EQUAL(a.countBonds(), 1)
	TEST_EQUAL(a.isBoundTo(b), true)
	TEST_EQUAL(a.createBond(bond, b), &bond)
	TEST_EQUAL(a.countBonds(), 1)
	TEST_EQUAL(a.isBoundTo(b), true)
	TEST_EQUAL(a.createBond(bond, c), &bond)
	TEST_EQUAL(a.countBonds(), 1)
	TEST_EQUAL(a.isBoundTo(b), false)
	TEST_EQUAL(a.isBoundTo(c), true)
RESULT

CHECK(Bond* getBond(Position index) throw(Exception::IndexOverflow))
	Atom a,b;
	Bond bond("", a,b);
	a.getBond(0)->setName("1234");
	TEST_EQUAL(bond.getName(), "1234")
	TEST_EXCEPTION(Exception::IndexOverflow, a.getBond(12))
RESULT

CHECK(const Bond* getBond(Position index) const throw(Exception::IndexOverflow))
	Atom a,b;
	Bond bond("", a,b);
	const Atom& ac = a;
	TEST_EQUAL(ac.getBond(0), &bond)
	TEST_EQUAL(ac.getBond(1), 0)
	TEST_EXCEPTION(Exception::IndexOverflow, ac.getBond(12))
RESULT

CHECK(Bond* getBond(const Atom& atom) throw())
	Atom a,b;
	Bond bond("", a,b);
	a.getBond(b)->setName("asdad");
	TEST_EQUAL(bond.getName(), "asdad")
RESULT

CHECK(const Bond* getBond(const Atom& atom) const throw())
	Atom a,b,c;
	Bond bond("", a,b);
	const Atom& ac = a;
	TEST_EQUAL(ac.getBond(b), &bond)
	TEST_EQUAL(ac.getBond(c), 0)
RESULT

CHECK(String getFullName(FullNameType type = ADD_VARIANT_EXTENSIONS) const throw())
	Fragment f;
	f.setName("fragment1");
	Atom a;
	a.setName("atom1");
	f.append(a);
	TEST_EQUAL(a.getFullName(), "fragment1:atom1")
RESULT

CHECK(void setTypeName(const String& name) throw())
	Atom a;
	a.setTypeName("asdd");
	TEST_EQUAL(a.getTypeName(), "asdd")
RESULT

CHECK(String getTypeName() const throw())
	TEST_EQUAL(ac.getTypeName(), BALL_ATOM_DEFAULT_TYPE_NAME)
RESULT

CHECK(bool applyBonds(UnaryProcessor<Bond>& processor) throw())
	ItemCollector<Bond> ic;
	Atom a,b,c,x;
	Bond bond1("", a,b);
	Bond bond2("", a,c);
	a.applyBonds(ic);
	TEST_EQUAL(ic.getList().size(), 2)
	list<Bond*>::iterator it = ic.getList().begin();
	TEST_EQUAL(*it, &bond1)
	it++;
	TEST_EQUAL(*it, &bond2)
	b.applyBonds(ic);
	TEST_EQUAL(ic.getList().size(), 1)
	x.applyBonds(ic);
	TEST_EQUAL(ic.getList().size(), 0)
RESULT

CHECK(bool isGeminal(const Atom& atom) const throw())
	Atom a,b,c,d;
	TEST_EQUAL(a.isGeminal(a), false)
	TEST_EQUAL(a.isGeminal(b), false)
	Bond bond1("", a,b);
	Bond bond2("", b,c);
	TEST_EQUAL(a.isGeminal(b), false)
	TEST_EQUAL(a.isGeminal(c), true)
	TEST_EQUAL(c.isGeminal(a), true)
RESULT

CHECK(bool isVicinal(const Atom& atom) const throw())
 	Atom a,b,c,d;
	TEST_EQUAL(a.isVicinal(a), false)
	TEST_EQUAL(a.isVicinal(b), false)
	Bond bond1("", a,b);
	Bond bond2("", b,c);
	Bond bond3("", c,d);
	TEST_EQUAL(a.isVicinal(b), false)
	TEST_EQUAL(a.isVicinal(c), false)
	TEST_EQUAL(a.isVicinal(d), true)
	TEST_EQUAL(d.isVicinal(a), true)
RESULT

CHECK(const Residue* getResidue() const throw())
	Atom a;
	TEST_EQUAL(a.getResidue(), 0)
	Fragment f;
	f.append(a);
	TEST_EQUAL(a.getResidue(), 0)
	Residue r;
	r.append(*(PDBAtom*) &a);
	TEST_EQUAL(a.getResidue(), &r)
RESULT

CHECK(const Chain* getChain() const throw())
	Atom a;
	TEST_EQUAL(a.getChain(), 0)
	Fragment f;
	f.append(a);
	TEST_EQUAL(a.getChain(), 0)
	Residue r;
	SecondaryStructure ss;
	ss.insert(r);
	Chain c;
	c.insert(ss);
	r.append(*(PDBAtom*) &a);
	TEST_EQUAL(a.getChain(), &c)
RESULT

CHECK(const SecondaryStructure* getSecondaryStructure() const throw())
	Atom a;
	TEST_EQUAL(a.getSecondaryStructure(), 0)
	Fragment f;
	f.append(a);
	TEST_EQUAL(a.getSecondaryStructure(), 0)
	Residue r;
	SecondaryStructure ss;
	ss.insert(r);
	r.append(*(PDBAtom*) &a);
	TEST_EQUAL(a.getSecondaryStructure(), &ss)
RESULT

CHECK(void dump(std::ostream& s = std::cout, Size depth = 0) const throw())
	Atom a(PTE[Element::HELIUM], "Atom1", "my_type_name", 'A',Vector3(1,2,3), Vector3(4,5,6), Vector3(7,8,9), 10.1, 11.2);

  String filename;
	NEW_TMP_FILE(filename)
	std::ofstream outfile(filename.c_str(), std::ios::out);
	a.dump(outfile);
	outfile.close();
	TEST_FILE_REGEXP(filename.c_str(), BALL_TEST_DATA_PATH(Atom_test.txt))
RESULT


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

END_TEST