Beispiel #1
0
        static void Main(string[] args)
        {
            var expression = ReadStringFromFile();

            var tree = new Tree.ExpressionTree(expression);

            Console.Write("Calculated value: ");
            Console.WriteLine(tree.Value);

            Console.Write("Tree representation: ");
            Console.WriteLine(tree.ToString());

            Console.Write("Infix representation: ");
            Console.WriteLine(tree.GetInfixRepresentation());
        }
Beispiel #2
0
        public void CorrectTests()
        {
            var tree = new Tree.ExpressionTree((string)TestContext.DataRow[0]);

            Assert.AreEqual(
                double.Parse((string)TestContext.DataRow["Result"]),
                tree.Value);

            Assert.AreEqual(
                (string)TestContext.DataRow[0],
                tree.ToString());

            Assert.AreEqual(
                (string)TestContext.DataRow["Infix"],
                tree.GetInfixRepresentation());
        }
Beispiel #3
0
 public void DividingByZeroShouldBeCathed()
 {
     var tree      = new Tree.ExpressionTree("(/ 1 0)");
     var treeValue = tree.Value;
 }
Beispiel #4
0
 public void ExceptionTests()
 {
     // Constructor runs calculations
     var tree = new Tree.ExpressionTree((string)TestContext.DataRow[0]);
 }