Examples of SGFTree


Examples of com.tinysgf.SGFTree

            for (int i = 0; i < data.length; i++) {
                InputStreamReader isr = new InputStreamReader(
                        new ByteArrayInputStream(data[i].getBytes()), "UTF8");
                SGFCup parser = new SGFCup(new SGFLex(isr));
                parser.parse();
                SGFTree tree = parser.tree;
/*        System.out.println(i);
                System.out.println(tree.toString());
                System.out.println(data[i]);
*/        assertEquals(data[i], tree.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
            fail("Unexpected!");
        }
View Full Code Here

Examples of com.tinysgf.SGFTree

        try {
            String data = "(;SZ[19](;B[da]C[RIGHT];W[ab])(;B[ad]))";
            InputStreamReader isr = new InputStreamReader(
                    new ByteArrayInputStream(data.getBytes()), "UTF8");
            SGFCup parser = new SGFCup(new SGFLex(isr));
            parser.tree = new SGFTree(1, 1);
            parser.parse();
            assertEquals(data, parser.tree.toString());
        } catch (Exception e) {
            e.printStackTrace();
            fail("Unexpected!");
View Full Code Here

Examples of com.tinysgf.SGFTree

import junit.framework.TestCase;

public class SGFTreeTest extends TestCase {

    public void testCollection() {
        SGFTree collection = new SGFTree();
        int root1 = collection.newNode();
        int root2 = collection.newNode();
        collection.linkVariant(root1, root2);
        assertEquals(SGFTree.ROOT, root1);
        assertEquals(SGFTree.NULL, collection.getPrev(root1));
        assertEquals(SGFTree.NULL, collection.getPrev(root2));
        assertEquals(root2, collection.getNextVariant(root1));
    }
View Full Code Here

Examples of com.tinysgf.SGFTree

        assertEquals(SGFTree.NULL, collection.getPrev(root2));
        assertEquals(root2, collection.getNextVariant(root1));
    }

    public void testNewNode() {
        SGFTree tree = new SGFTree();
        assertEquals(SGFTree.NONE, tree.getMoveProperty(SGFTree.ROOT));

        int m = tree.newNode();

        // add simple node
        int m1 = tree.newNode(m, SGFTree.BLACK_MOVE, 3, 4);
        assertEquals(SGFTree.BLACK_MOVE, tree.getMoveProperty(m1));
        assertEquals(3, tree.getMoveX(m1));
        assertEquals(4, tree.getMoveY(m1));
        assertEquals(m, tree.getPrev(m1));
        assertEquals(SGFTree.NULL, tree.getNext(m1));
        assertEquals(SGFTree.NULL, tree.getNextVariant(m1));
        assertEquals(m1, tree.getNext(m));

        // add variant
        int m2 = tree.newNode(m, SGFTree.BLACK_MOVE, 5, 6);
        assertEquals(m, tree.getPrev(m2));
        assertEquals(SGFTree.NULL, tree.getNext(m2));
        assertEquals(SGFTree.NULL, tree.getNextVariant(m2));
        assertEquals(m2, tree.getNextVariant(m1));
        assertEquals(m1, tree.getNext(m));
    }
View Full Code Here

Examples of com.tinysgf.SGFTree

        assertEquals(m2, tree.getNextVariant(m1));
        assertEquals(m1, tree.getNext(m));
    }

    public void testLinkNode() {
        SGFTree tree = new SGFTree();
        int m = tree.newNode();
        int m1 = tree.newNode(SGFTree.BLACK_MOVE, 3, 4);
        tree.linkNode(m, m1);
        assertEquals(SGFTree.BLACK_MOVE, tree.getMoveProperty(m1));
        assertEquals(3, tree.getMoveX(m1));
        assertEquals(4, tree.getMoveY(m1));
        assertEquals(m, tree.getPrev(m1));
        assertEquals(SGFTree.NULL, tree.getNext(m1));
        assertEquals(SGFTree.NULL, tree.getNextVariant(m1));
        assertEquals(m1, tree.getNext(m));
    }
View Full Code Here

Examples of com.tinysgf.SGFTree

        assertEquals(SGFTree.NULL, tree.getNextVariant(m1));
        assertEquals(m1, tree.getNext(m));
    }

    public void testRemoveNode() {
        SGFTree tree = new SGFTree();
        int m1 = tree.newNode(SGFTree.BLACK_MOVE, 3, 4);
        int m2 = tree.newNode(m1, SGFTree.WHITE_MOVE, 3, 5);
        int m2v2 = tree.newNode(m1, SGFTree.WHITE_MOVE, 3, 7);
        int m2v3 = tree.newNode(m1, SGFTree.WHITE_MOVE, 3, 8);
        int m3 = tree.newNode(m2, SGFTree.BLACK_MOVE, 4, 4);

        tree.removeNode(m3);
        assertEquals(SGFTree.NULL, tree.getNext(m2));
        int m3_ = tree.newNode(m2, SGFTree.BLACK_MOVE, 4, 9);
        assertEquals(m3_, m3);

        tree.removeNode(m2v2);
        assertEquals(m2v3, tree.getNextVariant(m2));
        tree.removeNode(m2);
        assertEquals(m2v3, tree.getNext(m1));
    }
View Full Code Here

Examples of com.tinysgf.SGFTree

        tree.removeNode(m2);
        assertEquals(m2v3, tree.getNext(m1));
    }

    public void testGetHead() {
        SGFTree tree = new SGFTree();
        int m1 = tree.newNode(SGFTree.BLACK_MOVE, 3, 4);
        int m2 = tree.newNode(m1, SGFTree.WHITE_MOVE, 3, 5);
        int m3 = tree.newNode(m2, SGFTree.BLACK_MOVE, 4, 4);
        assertEquals(m1, tree.getHead(m3));
    }
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.