$darkmode
DENOPTIM
SymmetricSetWithModeTest.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2022 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.graph;
20
21import static org.junit.jupiter.api.Assertions.assertEquals;
22import static org.junit.jupiter.api.Assertions.assertFalse;
23import static org.junit.jupiter.api.Assertions.assertNotEquals;
24import static org.junit.jupiter.api.Assertions.assertNull;
25import static org.junit.jupiter.api.Assertions.assertTrue;
26
27import java.util.HashSet;
28import java.util.Set;
29
30import javax.vecmath.Point3d;
31
32import org.junit.jupiter.api.Test;
33
35{
36
37//------------------------------------------------------------------------------
38
39 @Test
40 public void testEquals() throws Exception
41 {
44 SymmetricAPs s1 = v1.getSymmetricAPSets().get(0);
45 SymmetricAPs s2 = v2.getSymmetricAPSets().get(0);
46
47 SymmetricSetWithMode sm1 = new SymmetricSetWithMode(s1, "foo");
48 SymmetricSetWithMode sm2 = new SymmetricSetWithMode(s1, "foo");
49 assertTrue(sm1.equals(sm1));
50 assertTrue(sm1.equals(sm2));
51 assertTrue(sm2.equals(sm1));
52 assertFalse(sm1==sm2);
53
54 sm2.mode = "changed";
55 assertFalse(sm1.equals(sm2));
56 }
57
58//------------------------------------------------------------------------------
59
60 @Test
61 public void testHashCode() throws Exception
62 {
65 SymmetricAPs s1 = v1.getSymmetricAPSets().get(0);
66 SymmetricAPs s2 = v2.getSymmetricAPSets().get(0);
67
68 SymmetricSetWithMode sm1 = new SymmetricSetWithMode(s1, "foo");
69 SymmetricSetWithMode sm2 = new SymmetricSetWithMode(s1, "foo");
70
71 int hc1 = sm1.hashCode();
72 int hc2 = sm2.hashCode();
73 assertEquals(hc1, hc2);
74
75 sm2.mode = "changed";
76 hc2 = sm2.hashCode();
77 assertNotEquals(hc1, hc2);
78 }
79
80//------------------------------------------------------------------------------
81
82}
Unit test for DENOPTIMFragment.
static Fragment makeFragmentA()
A collection of AttachmentPoints that are related by a relation that we call "symmetry",...
Class coupling a reference to a SymmetricSet with a string that we call "mode" and can is used to sto...
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
Definition: Vertex.java:62
abstract List< SymmetricAPs > getSymmetricAPSets()