summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/model/PositionTest.java
blob: 1f7ca5f211c4e0121f0868afd54a5ce919e23386 (plain)
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
package jrummikub.model;

import java.util.HashSet;
import java.util.Set;

import org.junit.*;
import static org.junit.Assert.*;

/**
 * test functions of Position-Class
 * 
 */
public class PositionTest {

	/**
	 * String for debugging and testing
	 */
	@Test
	public void testToString() {
		Position pos = new Position(6, 2);
		assertEquals("Position[x=6.0,y=2.0]", pos.toString());
	}

	/**
	 * tests hashing
	 */
	@Test
	public void testEqualsAndHashCode() {
		Position pos1 = new Position(0, 0);
		Position pos2 = new Position(0, 0);
		Position pos3 = new Position(0, 1);
		Set<Position> set = new HashSet<Position>();
		set.add(pos1);
		assertTrue(set.contains(pos1));
		assertTrue(set.contains(pos2));
		assertFalse(set.contains(pos3));
	}

}