Gridarta Editor
Size2DTest.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 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 General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.utils;
21 
22 import org.junit.Assert;
23 import org.junit.Test;
24 
29 public class Size2DTest {
30 
34  @Test
35  public void testSize2D() {
36  final Size2D size = new Size2D(100, 200);
37  Assert.assertEquals("width MUST be stored", 100, size.getWidth());
38  Assert.assertEquals("height MUST be stored", 200, size.getHeight());
39  }
40 
44  @Test
45  public void testEquals() {
46  final Size2D size1 = new Size2D(100, 200);
47  final Size2D size2 = new Size2D(100, 200);
48  final Size2D size3 = new Size2D(100, 200);
49  final Size2D differWidth = new Size2D(50, 200);
50  final Size2D differHeight = new Size2D(100, 80);
51  final Size2D differBoth = new Size2D(50, 80);
52  Assert.assertEquals("Sizes with identical width and height MUST be equal.", size1, size2);
53  Assert.assertEquals("Sizes with identical width and height MUST be equal.", size1, size3);
54  Assert.assertEquals("Sizes with identical width and height MUST be equal.", size2, size1);
55  Assert.assertEquals("Sizes with identical width and height MUST be equal.", size2, size3);
56  Assert.assertEquals("Sizes with identical width and height MUST be equal.", size3, size1);
57  Assert.assertEquals("Sizes with identical width and height MUST be equal.", size3, size2);
58  Assert.assertNotEquals("Sizes with different width or height MUST be unequal", size1, differBoth);
59  Assert.assertNotEquals("Sizes with different width or height MUST be unequal", size1, differWidth);
60  Assert.assertNotEquals("Sizes with different width or height MUST be unequal", size1, differHeight);
61  }
62 
66  @Test
67  public void testHashCode() {
68  final Size2D size1 = new Size2D(100, 200);
69  final Size2D size2 = new Size2D(100, 200);
70  Assert.assertEquals("Equal sizes MUST return the same hashCode.", size1.hashCode(), size2.hashCode());
71  }
72 
76  @Test
77  public void testGetWidth() {
78  final Size2D size = new Size2D(100, 200);
79  Assert.assertEquals("width MUST be stored", 100, size.getWidth());
80  }
81 
85  @Test
86  public void testGetHeight() {
87  final Size2D size = new Size2D(100, 200);
88  Assert.assertEquals("height MUST be stored", 200, size.getHeight());
89  }
90 
91 }
net.sf.gridarta.utils.Size2D.getWidth
int getWidth()
Returns the width of the area.
Definition: Size2D.java:96
net.sf.gridarta.utils.Size2DTest
Test for Size2D.
Definition: Size2DTest.java:29
net.sf.gridarta.utils.Size2D.getHeight
int getHeight()
Returns the height of the area.
Definition: Size2D.java:104
net.sf.gridarta.utils.Size2DTest.testGetWidth
void testGetWidth()
Test case for Size2D#getWidth().
Definition: Size2DTest.java:77
net.sf.gridarta.utils.Size2DTest.testGetHeight
void testGetHeight()
Test case for Size2D#getHeight().
Definition: Size2DTest.java:86
net.sf.gridarta.utils.Size2DTest.testEquals
void testEquals()
Test case for Size2D#equals(Object).
Definition: Size2DTest.java:45
net.sf.gridarta.utils.Size2D.hashCode
int hashCode()
Definition: Size2D.java:88
net.sf.gridarta.utils.Size2DTest.testSize2D
void testSize2D()
Test case for Size2D#Size2D(int, int).
Definition: Size2DTest.java:35
net.sf.gridarta.utils.Size2D
The class Size2D represents a 2d rectangular area.
Definition: Size2D.java:30
net.sf.gridarta.utils.Size2DTest.testHashCode
void testHashCode()
Test case for Size2D#hashCode().
Definition: Size2DTest.java:67