$darkmode
DENOPTIM
ZMatrixBondTest.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2024 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.molecularmodeling.zmatrix;
20
21import static org.junit.jupiter.api.Assertions.assertEquals;
22import static org.junit.jupiter.api.Assertions.assertNotEquals;
23
24import org.junit.jupiter.api.Test;
25
32public class ZMatrixBondTest
33{
34//------------------------------------------------------------------------------
35
37 {
38 ZMatrixAtom atom1 = new ZMatrixAtom(0, "C", "C.3", null, null, null,
39 null, null, null, null);
40 ZMatrixAtom atom2 = new ZMatrixAtom(1, "H", "H.3", null, null, null,
41 null, null, null, null);
42 return new ZMatrixBond(atom1, atom2);
43 }
44
45//------------------------------------------------------------------------------
46
47 @Test
48 public void testEquals() throws Exception
49 {
52
53 assertEquals(bond1, bond1);
54 assertEquals(bond1, bond2);
55 assertNotEquals(bond1, null);
56
57 bond2.setAtm1(bond2.getAtm2());
58 assertNotEquals(bond1, bond2);
59 }
60
61//------------------------------------------------------------------------------
62
63 @Test
64 public void testZMatrixBondHashCode() throws Exception
65 {
66 ZMatrixAtom atom1 = new ZMatrixAtom(0, "C", "C.3", null, null, null,
67 null, null, null, null);
68 ZMatrixAtom atom2 = new ZMatrixAtom(1, "C", "C.3", null, null, null,
69 null, null, null, null);
70
71 ZMatrixBond bond1 = new ZMatrixBond(atom1, atom2);
72 ZMatrixBond bond2 = new ZMatrixBond(atom2, atom1); // Reversed order
73
74 assertEquals(bond1.hashCode(), bond2.hashCode(),
75 "Bonds with reversed order should have same hash code");
76 }
77
78//------------------------------------------------------------------------------
79
80}
81
Representation of an atom in the ZMatrix.
Definition: ZMatrixAtom.java:9
Representation of a bond in the ZMatrix.
Definition: ZMatrixBond.java:7
ZMatrixAtom getAtm2()
Get the second atom in the bond.
void setAtm1(ZMatrixAtom atm1)
Set the first atom in the bond.