public void Create_RotationOfSeperateTree() { var left = new AbstractSyntaxTreeNode("A"); var branchLeft = new AbstractSyntaxTreeNode("B"); var terminalLeft = new AbstractSyntaxTreeNode("C"); branchLeft.Append(terminalLeft); var branchRight = new AbstractSyntaxTreeNode("D"); var terminalRight = new AbstractSyntaxTreeNode("E"); branchRight.Append(terminalRight); left.Append(branchLeft); left.Append(branchRight); var right = new AbstractSyntaxTreeNode("A"); right.Append(branchRight.CopyDeep()); right.Append(branchLeft.CopyDeep()); var metric = Creator.Create(left, right); Assert.AreEqual( new AbstractSyntaxTreeMetric() { Insertations = 0, Deletions = 0, Rotations = 1 }, metric ); }
public void Create_OneDeletionsOfNode() { var left = new AbstractSyntaxTreeNode("A"); left.Append(new AbstractSyntaxTreeNode("B")); var right = left.CopyDeep(); left.Append(new AbstractSyntaxTreeNode("C")); var metric = Creator.Create(left, right); Assert.AreEqual(new AbstractSyntaxTreeMetric() { Deletions = 1, }, metric); }
public void Create_IdenticalTreeShouldBeNoDifference() { var left = new AbstractSyntaxTreeNode("A"); var terminal = new AbstractSyntaxTreeNode("B"); var branch = new AbstractSyntaxTreeNode("C"); branch.Append(terminal); left.Append(branch); left.Append(terminal.CopyDeep()); var right = left.CopyDeep(); var metric = Creator.Create(left, right); Assert.AreEqual(new AbstractSyntaxTreeMetric(), metric); }