Examples of SGFNode


Examples of com.sgfj.SGFNode

import junit.framework.TestCase;

public class SGFNodeBoundsVisitorTest extends TestCase {

    public void testWalk() {
        SGFNode node = new SGFNode();
        SGFMove wPass = new SGFMove(SGFMove.WHITE);
        node.addMoveProperty(wPass);
        SGFNode node2 = new SGFNode();
        SGFMove bPlay = new SGFMove(1, 10, SGFMove.BLACK);
        SGFMove wPlay = new SGFMove(3, 4, SGFMove.WHITE);
        node2.addMoveProperty(bPlay);
        node.add(node2);
        SGFNode node3 = new SGFNode();
        node3.addMoveProperty(wPlay);
        node.add(node3);

        SGFNodeBoundsVisitor bounds = new SGFNodeBoundsVisitor(0, 0, 19, 19);
        node.eval(bounds);
        assertEquals(1, bounds.xmin);
View Full Code Here

Examples of com.sgfj.SGFNode

        }
    }

    public void testGetProperty2() {
        try {
            SGFNode node = new SGFNode();
            SGFPointProperty pprop = new SGFPointProperty(SGFPropertyName.W, new SGFPoint(1, 2));
            node.addPropertyNoCheck(pprop);
            assertEquals(pprop, node.getProperty(SGFPropertyName.W));

            SGFIntProperty iprop = new SGFIntProperty(SGFPropertyName.SZ, 19);
            node.addPropertyNoCheck(iprop);
            assertEquals(iprop, node.getProperty(SGFPropertyName.SZ));
        } catch (Exception e) {
            e.printStackTrace();
            fail("No exceptions are expected.");
        }
    }
View Full Code Here

Examples of com.sgfj.SGFNode

        }
    }

    public void testGetComment() {
        try {
            SGFNode node = new SGFNode();
            try {
                node.getCommentProperty();
                fail("SGFPropertyNotFoundException expected!");
            } catch (SGFPropertyNotFoundException e) {
            }
            node.addProperty(new SGFTextProperty(SGFPropertyName.C, "a".toCharArray()));
            node.addProperty(new SGFTextProperty(SGFPropertyName.C, "b".toCharArray()));
            assertEquals("ab", node.getCommentProperty());
        } catch (Exception e) {
            e.printStackTrace();
            fail("No exceptions are expected.");
        }
    }
View Full Code Here

Examples of com.sgfj.SGFNode

        }
    }

    public void testAddMove() {
        try {
            SGFNode node = new SGFNode();
            node.addMoveProperty(new SGFMove(16, 3, SGFMove.BLACK));
            assertEquals(new SGFMove(16, 3, SGFMove.BLACK), node.getMoveProperty());
        } catch (Exception e) {
            e.printStackTrace();
            fail("No exceptions are expected.");
        }
    }
View Full Code Here

Examples of com.sgfj.SGFNode

            fail("No exceptions are expected.");
        }
    }

    public void testRemove() {
        SGFNode root = new SGFNode();
        SGFNode v1 = new SGFNode();
        SGFNode v2 = new SGFNode();
        SGFNode v3 = new SGFNode();
        SGFNode v3c = new SGFNode();
        root.add(v1);
        root.add(v2);
        root.add(v3);
        v2.add(v3c);
View Full Code Here

Examples of com.sgfj.SGFNode

        assertSame(null, v3.iterator().nextVariant(false));
        assertSame(null, v3.iterator().next(false));
    }

    public void testPlay() {
        SGFNode root = new SGFNode();
        SGFMove m1 = new SGFMove(0, 0, SGFMove.WHITE);
        SGFMove m2 = new SGFMove(0, 1, SGFMove.BLACK);
        SGFMove m3 = new SGFMove(1, 0, SGFMove.BLACK);
        root.play(m1);
        root.iterator().next(false).play(m2);
        root.iterator().next(false).play(m3);
        root.iterator().next(false).play(m2);
        SGFNodeIterator it = root.iterator();
        try {
            assertEquals(m1, it.next(true).getMoveProperty());
            assertEquals(m2, it.next(true).getMoveProperty());
            assertEquals(m3, it.nextVariant(true).getMoveProperty());
            assertEquals(null, it.nextVariant(true));
View Full Code Here

Examples of com.sgfj.SGFNode

    }

    public void testEquals() {
        try {
            setUp();
            SGFNode tmp = tree;
            tree = null;
            setUp();
            assertEquals(tmp, tree);
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of com.sgfj.SGFNode

    public void testWrite() {
        try {
            String data = "(;GM[1]FF[4]CA[UTF-8]AP[CGoban:3]ST[2]RU[Japanese]SZ[9]HA[3]KM[5.50]PW[White]PB[Black]AB[gc][cg][gg];W[ed]CR[ee]TR[cc][gc](;B[ec]CR[ec]LB[dd:A])(;B[eg]CR[eg];W[];B[ge]))";
            SGFParser reader = new SGFParser(data);
            SGFNode tree = reader.parse();
            assertNotNull("Emty tree received.", tree);

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            OutputStreamWriter w = new OutputStreamWriter(baos);
            SGFWriter.write(w, tree);
            w.close();

            //System.out.println(baos.toString());
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            reader = new SGFParser(new InputStreamReader(bais));
            SGFNode tree2 = reader.parse();

            assertEquals(tree, tree2);
            assertEquals(SGFWriter.toString(tree), SGFWriter.toString(tree2));
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of com.sgfj.SGFNode

        }
    }

    public void testWriteSynth() {
        try {
            SGFNode root = new SGFNode();
            root.addProperty(new SGFIntProperty(SGFPropertyName.SZ, 9));
            root.addProperty(new SGFIntProperty(SGFPropertyName.HA, 0));

            SGFNode n;
            String s;

            n = new SGFNode();
            n.addMoveProperty(new SGFMove(0, 0, SGFMove.BLACK));
            root.add(n);
            s = SGFWriter.toString(root);
            assertEquals("(;SZ[9]HA[0];B[aa])", s);

            n = new SGFNode();
            n.addMoveProperty(new SGFMove(1, 1, SGFMove.WHITE));
            root.add(n);
            s = SGFWriter.toString(root);
            assertEquals("(;SZ[9]HA[0](;B[aa])(;W[bb]))", s);
        } catch (IOException e) {
            e.printStackTrace();
View Full Code Here

Examples of com.sgfj.SGFNode

     */
    public void testParse() {
        try {
            SGFParser reader = new SGFParser(cgobanData);
            //FileInputStream is = new FileInputStream("data/1850-11-17-Shusaku-Ito.Showa.sgf");
            SGFNode tree = reader.parse();
            assertNotNull("Emty tree received.", tree);

            SGFNodeIterator i = tree.iterator();
            SGFPointProperty move;

            assertFalse(i.current().hasProperty(SGFPropertyName.W));
            assertFalse(i.current().hasProperty(SGFPropertyName.B));
            assertNull(i.prev(false));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.