summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/model/PositionTest.java
blob: 2812f9c68edb3cbc712fa05ee1faa4d00d4623f2 (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
package jrummikub.model;

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

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

public class PositionTest {

	@Test
	public void testToString() {
		Position pos = new Position(6, 2);
		assertEquals("Position[x=6.0,y=2.0]", pos.toString());
	}

	@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));
	}

}