package org.mahjong4j.hands;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;
import static org.mahjong4j.tile.MahjongTile.*;

/**
 * @author yu1ro
 */
public class KotsuTest {
    private Kotsu open;
    private Kotsu close;
    private Kotsu closeFls;

    @Before
    public void setUp() throws Exception {
        open = new Kotsu(true, TON);
        close = new Kotsu(false, SHA, SHA, SHA);
        closeFls = new Kotsu(false, HAK, HAK, CHN);
    }

    @Test
    public void testCheckTrue() throws Exception {
        assertTrue(Kotsu.check(S2, S2, S2));
        assertTrue(Kotsu.check(HAK, HAK, HAK));
        assertTrue(Kotsu.check(NAN, NAN, NAN));
    }

    @Test
    public void testCheckFalse() throws Exception {
        assertFalse(Kotsu.check(P2, P2, P4));
        assertFalse(Kotsu.check(HAK, CHN, CHN));
        assertFalse(Kotsu.check(TON, NAN, SHA));
    }

    @Test
    public void testGetTile() throws Exception {
        assertEquals(TON, open.getTile());
        assertEquals(SHA, close.getTile());
        assertNull(closeFls.getTile());
    }

    @Test
    public void testGetIsMentsu() throws Exception {
        assertTrue(open.getIsMentsu());
        assertTrue(close.getIsMentsu());
        assertFalse(closeFls.getIsMentsu());
    }

    @Test
    public void testGetIsOpen() throws Exception {
        assertTrue(open.getIsOpen());
        assertFalse(close.getIsOpen());
        assertFalse(closeFls.getIsOpen());
    }
}
@@ -281,16 +281,41 @@
 loseFls;
+%0A    private Kotsu equal;
 %0A%0A    @B
@@ -497,24 +497,72 @@
  HAK, CHN);%0A
+        equal = new Kotsu(true, TON, TON, TON);%0A
     %7D%0A%0A    @
@@ -1554,10 +1554,447 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testEquals() throws Exception %7B%0A        assertTrue(open.equals(equal));%0A        assertFalse(open.equals(close));%0A        assertFalse(open.equals(closeFls));%0A    %7D%0A%0A    @Test%0A    public void testHashCode() throws Exception %7B%0A        assertEquals(open.hashCode(), equal.hashCode());%0A        assertNotEquals(open.hashCode(), close.hashCode());%0A        assertNotEquals(open.hashCode(), closeFls.hashCode());%0A    %7D
 %0A%7D

add Kotsu equals and hashCode test