package net.woodyfolsom.msproj;

import static org.junit.Assert.assertEquals;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.antlr.runtime.RecognitionException;
import org.junit.Test;

public class RefereeTest {
	//private static final String FILENAME = "data/tourney1/gogame-121115115720-0500.sgf";
	private static final String FILENAME = "data/games/1334-gokifu-20120916-Gu_Li-Lee_Sedol.sgf";
	
	@Test
	public void testReplay() throws IOException, RecognitionException {
		File sgfFile = new File(FILENAME);
		InputStream fis = new FileInputStream(sgfFile);

		GameRecord gameRecord = Referee.replay(fis);

		fis.close();
		
		//assertEquals(9, gameRecord.getGameConfig().getSize());
		assertEquals(19, gameRecord.getGameConfig().getSize());
		
		//assertEquals(5.5, gameRecord.getGameConfig().getKomi(), 0.1);
		assertEquals(7.5, gameRecord.getGameConfig().getKomi(), 0.1);
		
		//assertEquals(74, gameRecord.getNumTurns());
		assertEquals(214, gameRecord.getNumTurns());
		
		System.out.println("Final board state (LaTeX): ");
		LatexWriter.write(System.out, gameRecord, 214);
		
		System.out.println("Final board state (SGF): ");
		SGFWriter.write(System.out, gameRecord);
		
	}
}
