public void Node_without_properties() { var encoded = "(;)"; var expected = new SgfTree(new Dictionary <string, string[]>()); AssertEqual(expected, SgfParser.ParseTree(encoded)); }
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)); }
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)); }
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]); } }
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)); }
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)); }
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)); }
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)); }
private static SgfTree TreeWithSingleChild(IDictionary <string, string[]> data, SgfTree child) => new SgfTree(data, child);