/Excel.Expressions.Test/Test8 (2).cs
C# | 363 lines | 236 code | 35 blank | 92 comment | 8 complexity | e46b7508fc51cbbedb1e71fbc1230489 MD5 | raw file
- using System.Diagnostics;
- using System.Globalization;
- using Excel.Expressions.Compiler;
- using Expressions.Compiler;
- using Expressions.Compiler.Interfaces;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using Excel.Expressions.Interfaces;
-
- namespace Tests
- {
-
-
- /// <summary>
- ///This is a test class for Test8_ and is intended
- ///to contain all Test8_ Unit Tests
- ///</summary>
- [TestClass()]
- public class Test8__
- {
-
-
- private TestContext testContextInstance;
-
- /// <summary>
- ///Gets or sets the test context which provides
- ///information about and functionality for the current test run.
- ///</summary>
- public TestContext TestContext
- {
- get
- {
- return testContextInstance;
- }
- set
- {
- testContextInstance = value;
- }
- }
-
- #region Additional test attributes
- //
- //You can use the following additional attributes as you write your tests:
- //
- //Use ClassInitialize to run code before running the first test in the class
- //[ClassInitialize()]
- //public static void MyClassInitialize(TestContext testContext)
- //{
- //}
- //
- //Use ClassCleanup to run code after all tests in a class have run
- //[ClassCleanup()]
- //public static void MyClassCleanup()
- //{
- //}
- //
- //Use TestInitialize to run code before running each test
- //[TestInitialize()]
- //public void MyTestInitialize()
- //{
- //}
- //
- //Use TestCleanup to run code after each test has run
- //[TestCleanup()]
- //public void MyTestCleanup()
- //{
- //}
- //
- #endregion
-
- private static Parser CreateGrammar()
- {
- Nonterminal G = "G";
- G.Definition = new Rules()
- {
- () => "5.25"
- };
- Parser input = "5.25";
-
- G.Initialize();
- G.Validate();
-
- G.Parse(input);
- return input;
- }
-
- /// <summary>
- ///A test for Terminal Constructor
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_1()
- {
- string ch = string.Empty;
- Terminal expected = Terminal.Null;
- Terminal actual = ch;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for Parse
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_2()
- {
- char ch = ')';
- Terminal target = ch;
- Parser input = ")";
- bool expected = true;
- bool actual;
- actual = target.Parse(input) == true;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for ToString
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_3()
- {
- char ch = ')';
- Terminal target = ch;
- string expected = ")";
- string actual;
- actual = target.Name;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for op_Implicit
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_4()
- {
- Terminal terminal = '(';
- string expected = "(";
- string actual;
- actual = terminal.Name;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_7()
- {
- string ch = null;
- Terminal terminal = ((Terminal)ch)[true];
- string expected = "(|)";
- string actual = terminal.Name;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_20()
- {
- string key = Terminal.Null.ToString();
- Terminal terminal = ((Terminal)key)[true];
- string expected = "(|)";
- string actual = terminal.Name;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_8()
- {
- string ch = null;
- string key = Terminal.Null.ToString();
- Parser text = (Parser)ch;
- Terminal terminal = ((Terminal)ch)[true];
- text = "(|)";
- string expected = "(|)";
- string actual = terminal.Name;
- Assert.AreEqual(expected, actual);
- }
-
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_9()
- {
- string ch = "(|)";
- string key = Terminal.Null.ToString();
- Parser text = (Parser)null;
- Terminal terminal = ((Terminal)ch)[true];
- text = "(|)";
- Nonterminal G = "G";
- G.Definition = new Rules
- {
- () => '(' + Terminal.Null.ToString()
- };
-
- bool expected = false;
-
- G.Initialize();
- G.Validate();
-
- bool actual = G.Parse(text);
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_10()
- {
- string key = Terminal.Null.ToString();
- Parser text = null;
- string expected = null;
- string actual = (string)text;
- Assert.AreEqual(expected, actual);
- }
-
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_11()
- {
- string key = "uiop";
- Parser text = key;
- text.Close();
- bool expected = true;
- bool actual = text.Tree == null;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_12()
- {
- Parser text = "uiop";
- Terminal u = Terminal.Null;
- string expected = Terminal.Null.ToString();
- string actual = u.Value;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_13()
- {
- Parser text = "uiop";
- Terminal u = "uiop";
- string expected = "uiop";
- string actual = u.Value;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_14()
- {
- Parser text = "(|)";
- string expected = "(|)";
- string actual = text.ToString();
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_15()
- {
- Parser input = CreateGrammar();
- Number text = new Number(input.Tree[0].Context.ToString());
- bool expected = true;
- bool actual = text == 5.25;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod()]
- public void Test8_16()
- {
- string value = "5.25";
- Parser input = CreateGrammar();
- Number text = new Number(input.Tree[0].Context.ToString());
- bool expected = true;
- bool actual = string.Compare(text.Eval().ToString(CultureInfo.InvariantCulture), value) == 0;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test8_17()
- {
- Parser input = CreateGrammar();
- Number a = new Number(input.Tree[0].Context.ToString());
- Number b = new Number(input.Tree[0].Context.ToString());
- Plus add = new Plus(a, b);
- bool expected = true;
- bool actual = a + b == add;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test9_18()
- {
- Parser input = CreateGrammar();
- Number a = new Number(input.Tree[0].Context.ToString());
- Number b = new Number(input.Tree[0].Context.ToString());
- Minus sub = new Minus(a, b);
- bool expected = true;
- bool actual = a - b == sub;
- Assert.AreEqual(expected, actual);
- }
-
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test9_19()
- {
- Parser input = CreateGrammar();
- Number a = new Number(input.Tree[0].Context.ToString());
- Number b = new Number(input.Tree[0].Context.ToString());
- Mul mul = new Mul(a, b);
- bool expected = true;
- bool actual = a * b == mul;
- Assert.AreEqual(expected, actual);
- }
-
- /// <summary>
- ///A test for null
- ///</summary>
- [TestMethod(), Conditional("DEBUG")]
- public void Test9_20()
- {
- Parser input = CreateGrammar();
- Number a = new Number(input.Tree[0].Context.ToString());
- Number b = new Number(input.Tree[0].Context.ToString());
- Div div = new Div(a, b);
- bool expected = true;
- bool actual = a / b == div;
- Assert.AreEqual(expected, actual);
- }
- }
- }