$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.assertTrue;
25
26import org.junit.jupiter.api.Test;
27
29{
30
31//------------------------------------------------------------------------------
32
33 @Test
34 public void testEquals() throws Exception
35 {
38 SymmetricAPs s1 = v1.getSymmetricAPSets().get(0);
39 SymmetricAPs s2 = v2.getSymmetricAPSets().get(0);
40
41 SymmetricSetWithMode sm1 = new SymmetricSetWithMode(s1, "foo");
42 SymmetricSetWithMode sm2 = new SymmetricSetWithMode(s1, "foo");
43 assertTrue(sm1.equals(sm1));
44 assertTrue(sm1.equals(sm2));
45 assertTrue(sm2.equals(sm1));
46 assertFalse(sm1==sm2);
47
48 sm2.mode = "changed";
49 assertFalse(sm1.equals(sm2));
50 }
51
52//------------------------------------------------------------------------------
53
54 @Test
55 public void testHashCode() throws Exception
56 {
59 SymmetricAPs s1 = v1.getSymmetricAPSets().get(0);
60 SymmetricAPs s2 = v2.getSymmetricAPSets().get(0);
61
62 SymmetricSetWithMode sm1 = new SymmetricSetWithMode(s1, "foo");
63 SymmetricSetWithMode sm2 = new SymmetricSetWithMode(s1, "foo");
64
65 int hc1 = sm1.hashCode();
66 int hc2 = sm2.hashCode();
67 assertEquals(hc1, hc2);
68
69 sm2.mode = "changed";
70 hc2 = sm2.hashCode();
71 assertNotEquals(hc1, hc2);
72 }
73
74//------------------------------------------------------------------------------
75
76}
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:61
abstract List< SymmetricAPs > getSymmetricAPSets()