Esempio n. 1
0
    public void Node_without_properties()
    {
        var encoded  = "(;)";
        var expected = new SgfTree(new Dictionary <string, string[]>());

        AssertEqual(expected, SgfParser.ParseTree(encoded));
    }
Esempio n. 2
0
    public void Multiple_properties()
    {
        var encoded  = "(;A[b]C[d])";
        var expected = new SgfTree(new Dictionary <string, string[]> {
            ["A"] = new[] { "b" }, ["C"] = new[] { "d" }
        });

        AssertEqual(expected, SgfParser.ParseTree(encoded));
    }
Esempio n. 3
0
    public void Single_node_tree()
    {
        var encoded  = "(;A[B])";
        var expected = new SgfTree(new Dictionary <string, string[]> {
            ["A"] = new[] { "B" }
        });

        AssertEqual(expected, SgfParser.ParseTree(encoded));
    }
Esempio n. 4
0
 private void AssertEqual(SgfTree expected, SgfTree actual)
 {
     Assert.Equal(expected.Data, actual.Data);
     Assert.Equal(expected.Children.Length, actual.Children.Length);
     for (var i = 0; i < expected.Children.Length; i++)
     {
         AssertEqual(expected.Children[i], actual.Children[i]);
     }
 }
Esempio n. 5
0
    public void Escaped_property()
    {
        var encoded  = "(;A[\\]b\\nc\\nd\\t\\te \\n\\]])";
        var expected = new SgfTree(new Dictionary <string, string[]> {
            ["A"] = new[] { "]b\nc\nd  e \n]" }
        });

        AssertEqual(expected, SgfParser.ParseTree(encoded));
    }
Esempio n. 6
0
    public void Multiple_property_values()
    {
        var encoded  = "(;A[b][c][d])";
        var expected = new SgfTree(new Dictionary <string, string[]> {
            ["A"] = new[] { "b", "c", "d" }
        });

        Assert.Equal(expected, SgfParser.ParseTree(encoded));
    }
Esempio n. 7
0
    public void Two_nodes()
    {
        var encoded  = "(;A[B];B[C])";
        var expected = new SgfTree(new Dictionary <string, string[]> {
            ["A"] = new[] { "B" }
        }, new SgfTree(new Dictionary <string, string[]> {
            ["B"] = new[] { "C" }
        }));

        AssertEqual(expected, SgfParser.ParseTree(encoded));
    }
Esempio n. 8
0
    public void Two_child_trees()
    {
        var encoded  = "(;A[B](;B[C])(;C[D]))";
        var expected = new SgfTree(new Dictionary <string, string[]> {
            ["A"] = new[] { "B" }
        }, new SgfTree(new Dictionary <string, string[]> {
            ["B"] = new[] { "C" }
        }), new SgfTree(new Dictionary <string, string[]> {
            ["C"] = new[] { "D" }
        }));

        AssertEqual(expected, SgfParser.ParseTree(encoded));
    }
Esempio n. 9
0
 private static SgfTree TreeWithSingleChild(IDictionary <string, string[]> data, SgfTree child) => new SgfTree(data, child);